# file : tests/test/script/runner/set.test # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file .include ../common.test : special : { : pipelining : $c <'set foo | cat >bar' && $b 2>>EOE != 0 testscript:1:1: error: set builtin must be the last pipe command EOE : redirecting : { : stdout : $c <'set foo >bar' && $b 2>>EOE != 0 testscript:1:1: error: set builtin stdout cannot be redirected EOE : stderr : $c <'set foo 2>bar' && $b 2>>EOE != 0 testscript:1:1: error: set builtin stderr cannot be redirected EOE } : status : $c <'set foo == 1' && $b 2>>EOE != 0 testscript:1:1: error: set builtin exit code cannot be non-zero EOE } : arguments : { : none : $c <'set -e' && $b 2>>EOE != 0 testscript:1:1: error: missing variable name EOE : unexpected : $c <'set foo bar baz' && $b 2>>EOE != 0 testscript:1:1: error: unexpected argument EOE : empty-attrs : $c <"set '' baz" && $b 2>>EOE != 0 testscript:1:1: error: empty variable attributes EOE : empty-var : $c <"set ''" && $b 2>>EOE != 0 testscript:1:1: error: empty variable name EOE } : whitespace-separated-list : { : non-exact : $c <'foo bar' EOI : exact : { : trailing-ws : $c <'foo bar ' EOI : no-trailing-ws : : Note that we need to strip the default trailing newline as well with the : ':' modifier. : $c <'foo bar' EOI } } : newline-separated-list : { : non-exact : $c <' foo bar ' EOI : exact : { : trailing-newline : $c <' foo bar ' EOI : no-trailing-newline : $c <' foo bar' EOI } } : string : { : non-exact : $c <>EOO foo bar EOO EOI : roundtrip : echo 'foo' | set bar; echo "$bar" >'foo' : exact : : Note that echo adds the trailing newline, so EOF and EOO here-documents : differ by this newline. : { : trailing-newline : $c <>EOO foo bar EOO EOI : no-trailing-newline : $c <>EOO foo bar EOO EOI } } : attributes : { : dir_path : $c </'foo/' EOI : null : $c <'' EOI : none : $c <>EOE != 0 set -w baz <'foo bar'; echo "$baz" EOI testscript:2:8: error: concatenating variable expansion contains multiple values EOE # @@ Move the following tests to build2 parser unit tests when created. # : empty-brackets : $c <>EOE != 0 set -w '[]' baz <'foo bar'; echo "$baz" EOI testscript:2:8: error: concatenating variable expansion contains multiple values EOE : no-left-bracket : $c <>EOE != 0 set -w x baz EOI :1:1: error: expected '[' instead of 'x' testscript:1:1: info: while parsing attributes 'x' EOE : unknown : $c <>EOE != 0 set -w [x] baz EOI :1:1: error: unknown value attribute x testscript:1:1: info: while parsing attributes '[x]' EOE : junk : $c <>EOE != 0 set -w '[string] x' baz EOI :1:10: error: trailing junk after ']' testscript:1:1: info: while parsing attributes '[string] x' EOE }