aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-10-14 12:21:31 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-10-14 17:30:12 +0300
commitfbe94f38ee51e705202a2d5cf1f45b5e8a08d8c7 (patch)
tree3f1881370b61da5f217a6907e37ca1945387e50a
parent74eea8fe332c05774f108c5094eb335e58f44cfa (diff)
Make -w|--whitespace to be default for for-loop
-rw-r--r--libbuild2/script/parser.cxx2
-rw-r--r--tests/test/script/runner/for.testscript23
2 files changed, 18 insertions, 7 deletions
diff --git a/libbuild2/script/parser.cxx b/libbuild2/script/parser.cxx
index 7989c20..a2e0819 100644
--- a/libbuild2/script/parser.cxx
+++ b/libbuild2/script/parser.cxx
@@ -2521,7 +2521,7 @@ namespace build2
stream_reader sr (
move (in), pipe,
- ops.whitespace (), ops.newline (), ops.exact (),
+ !ops.newline (), ops.newline (), ops.exact (),
dl, deadline_cmd,
ll);
diff --git a/tests/test/script/runner/for.testscript b/tests/test/script/runner/for.testscript
index 1ac7666..85ea765 100644
--- a/tests/test/script/runner/for.testscript
+++ b/tests/test/script/runner/for.testscript
@@ -172,6 +172,17 @@
b
EOO
+ : both-sep-options
+ :
+ $c <<EOI && $b 2>>/~%EOE% != 0
+ echo "a b" | for -n -w x
+ echo $x >|
+ end
+ EOI
+ testscript:1:1: error: for: both -n|--newline and -w|--whitespace specified
+ %.+
+ EOE
+
: invalid-option
:
$c <<EOI && $b 2>>/~%EOE% != 0
@@ -183,7 +194,6 @@
%.+
EOE
-
: no-variable
:
$c <<EOI && $b 2>>/~%EOE% != 0
@@ -219,7 +229,7 @@
: exit
:
$c <<EOI && $b >>EOO
- for x: a b
+ echo "a b" | for x
echo "$x" >|
exit
end
@@ -230,7 +240,7 @@
: error
:
$c <<EOI && $b >>EOO 2>>EOE != 0
- for x: a b
+ echo "a b" | for x
echo "$x" >|
exit 'fed up'
end
@@ -325,7 +335,8 @@
echo $x >|
end
EOI
- a b/
+ a/
+ b/
EOO
: nested
@@ -419,7 +430,7 @@
: exit
:
$c <<EOI && $b >>EOO
- for x: a b
+ for x <"a b"
echo "$x" >|
exit
end
@@ -430,7 +441,7 @@
: error
:
$c <<EOI && $b >>EOO 2>>EOE != 0
- for x: a b
+ for x <"a b"
echo "$x" >|
exit 'fed up'
end