diff options
| author | Shulhan <ms@kilabit.info> | 2023-11-10 15:07:52 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-11-11 18:37:15 +0700 |
| commit | d8b7a4e509a641ea2949646c5a3577bc848fea30 (patch) | |
| tree | 09f9bb2d3f3afe83a17fc2c1e85cba606da276b7 /script.go | |
| parent | cf6d0e5bb0baf5acbc70f8084d087e3a41b5452e (diff) | |
| download | awwan-d8b7a4e509a641ea2949646c5a3577bc848fea30.tar.xz | |
script: respect spaces when joining multi lines command
If a multi lines command does not have spaces or have multiple
spaces, join them as is.
For example,
a\
b
should return the value as "ab", while
a \
b
should return "a b".
Diffstat (limited to 'script.go')
| -rw-r--r-- | script.go | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -197,12 +197,13 @@ func joinStatements(in [][]byte) (out [][]byte) { continue } - stmt = bytes.TrimRight(stmt, "\\ \t") - stmt = append(stmt, ' ') + // Start joining multiline statement. + + stmt = bytes.TrimRight(stmt, "\\") y = x + 1 for ; y < len(in); y++ { - nextStmt = bytes.TrimSpace(in[y]) + nextStmt = in[y] if len(nextStmt) == 0 { in[y] = nil out[y] = nil @@ -213,10 +214,8 @@ func joinStatements(in [][]byte) (out [][]byte) { lastc = nextStmt[endc] if lastc == '\\' { - nextStmt = bytes.TrimRight(nextStmt, "\\ \t") - nextStmt = append(nextStmt, ' ') + nextStmt = bytes.TrimRight(nextStmt, "\\") } - stmt = append(stmt, nextStmt...) in[y] = nil |
