aboutsummaryrefslogtreecommitdiff
path: root/script.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-11-10 15:07:52 +0700
committerShulhan <ms@kilabit.info>2023-11-11 18:37:15 +0700
commitd8b7a4e509a641ea2949646c5a3577bc848fea30 (patch)
tree09f9bb2d3f3afe83a17fc2c1e85cba606da276b7 /script.go
parentcf6d0e5bb0baf5acbc70f8084d087e3a41b5452e (diff)
downloadawwan-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.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/script.go b/script.go
index 0d0b1b1..dd54eac 100644
--- a/script.go
+++ b/script.go
@@ -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