Lines Matching full:echo

1 #!/bin/echo no
20 # backslash not discarded: echo "abc\"def"
32 # touch 'AB[DEF]'; echo AB[+(DEF]) AB[+(DEF)?
59 shxpect "prompt and echo" I$'echo hello\n' O$'hello\n' E"$P"
60 shxpect "redirect err" I$'echo > /dev/full\n' E E"$P"
61 shxpect "wait for <(exit)" I$'cat <(echo hello 1>&2)\n' E$'hello\n' E"$P"
64 testing '-c "" exit status 0' '$SH -c "" && echo $?' '0\n' '' ''
65 testing '-c args' "\$SH -c 'echo \$0,\$1,\$2,\$3' one two three four five" \
67 testing '-c args2' "\$SH -c 'echo \${10}' a b c d e f g h i j k l" "k\n" "" ""
69 "$SH -c 'for i in a\"\$@\"b;do echo =\$i=;done;echo \$0' 123 456 789" \
72 "$SH -c 'for i in a\"\$* \$@\"b; do echo =\$i=;done' one two three four five"\
74 testing '-c arg count' "$SH -c 'echo \$#' 9 8 7 6 1 2 3 4" "7\n" "" ""
77 testing 'arg shift' "$SH -c '"'for i in "" 2 1 1 1; do echo $? $1; shift $i; done'"' one two three …
79 testing '(subshell)' '$SH -c "(echo hello)"' 'hello\n' '' ''
80 testing 'syntax' '$SH -c "if true; then echo hello | fi" 2>/dev/null || echo x'\
85 testing 'non-absolute $_' "./bash -c 'echo \$_'" './bash\n' '' ''
89 E E"$P" I$'echo $_\n' O$'hello\n'
91 E E"$P" I$'echo $_\n' O$'hello\n'
93 E E"$P" I$'echo $_\n' O$'hello\n'
95 testing '$_ literal after exec' 'env >/dev/null; echo $_' 'env\n' '' ''
96 shxpect '$_ no path for builtin' I$'true; echo $_\n' O$'true\n'
97 testing 'prefix is local for builtins' 'abc=123; abc=def unset abc; echo $abc' \
100 'SECONDS=123; SECONDS=345 true; echo $SECONDS' '123\n' '' ''
102 testing '$NOTHING clears $_' 'true; $NOTHING; echo $_' '\n' '' ''
104 testing 'exec exitval' "$SH -c 'exec echo hello' && echo \$?" "hello\n0\n" "" ""
105 testing 'simple script' '$SH input' 'input\n' 'echo $0' ''
106 testing 'simple script2' '$SH ./input two;echo $?' './input+two\n42\n' \
110 '$SH input 2>/dev/null; [ $? -lt 128 ] && echo pass' 'pass\n' \
112 testing '$LINENO 1' "$SH input" "1\n" 'echo $LINENO' ''
115 echo echo hello > sub/script
121 testing 'IFS $*' "$SH -c 'IFS=xy; echo \"\$*\"' one two tyree" "twoxtyree\n" \
130 '#!/bin/bash\n\nfor i in one two\ndo\n echo $LINENO $i\n echo $LINENO $i\ndone\n' ""
131 testing "eval0" "sh -c 'eval echo \$*' one two three" "two three\n" "" ""
137 testing "smoketest" "echo hello" "hello\n" "" ""
139 testing "eval" "eval echo hello" "hello\n" "" ""
140 testing "eval2" "eval 'echo hello'; echo $?" "hello\n0\n" "" ""
141 testing "eval3" 'X="echo hello"; eval "$X"' "hello\n" "" ""
143 NOSPACE=1 testing "eval5" 'eval echo \" hello \" | wc' ' 1 1 8' "" ""
144 testing "exec" "exec echo hello" "hello\n" "" ""
145 testing "exec2" "exec echo hello; echo $?" "hello\n" "" ""
148 testing "semicolon" "echo one;echo two" "one\ntwo\n" "" ""
149 testing "simple pipe" "echo hello | cat" "hello\n" "" ""
150 testing "&&" "true && echo hello" "hello\n" "" ""
151 testing "&&2" "false && echo hello" "" "" ""
152 testing "||" "true || echo hello" "" "" ""
153 testing "||2" "false || echo hello" "hello\n" "" ""
154 testing "&& ||" "true && false && potato || echo hello" "hello\n" "" ""
155 testing "&& after function" "x(){ false;};x && echo yes" "" "" ""
156 testing "|| after function" "x(){ false;};x || echo yes" "yes\n" "" ""
161 testing "redir2" "echo blah >out; cat out" "blah\n" "" ""
162 testing "redir3" "echo more >>out; cat out" "blah\nmore\n" "" ""
168 testing "redir8" 'echo -n $(<input)' "boing" "boing\n" ""
169 shxpect "redir9" I$'echo hello > out 2>/does/not/exist\n' E E"$P" \
171 testing "redir10" 'echo hello 3<&3' "hello\n" "" ""
172 testing "redir11" 'if :;then echo one;fi {abc}<input; cat <&$abc' \
178 testing "tilde expansion" "echo ~" "$HOME\n" "" ""
179 testing "tilde2" "echo ~/dir" "$HOME/dir\n" "" ""
181 "echo {A{a,b}B{c,d}C}" "{AaBcC} {AaBdC} {AbBcC} {AbBdC}\n" "" ""
182 testing "brackets2" "echo {A{a,b}B{c,d}C,D}" "AaBcC AaBdC AbBcC AbBdC D\n" "" ""
183 testing "brackets3" 'echo {A"b,c"D}' "{Ab,cD}\n" "" ""
184 testing "brackets4" 'echo {A"bc",D}' "Abc D\n" "" ""
185 testing "brackets5" 'echo {A,B,C' "{A,B,C\n" "" ""
186 testing "brackets6" 'echo {{{{A,B},C}D},E}' "{AD} {BD} {CD} E\n" "" ""
187 testing "brackets7" 'echo {{{a,b},c,{d,e}},f}' "a b c d e f\n" "" ""
188 testing "brackets8" 'echo A{a{b,c{B,C}D}d{e,f},g{h,i}j}E' \
190 testing "brackets9" 'echo A{B{C,D}E{N,O},F{G,H}I}J{K,L}M' \
193 testing "bracket+tilde" "echo {~,~root}/pwd" "$HOME/pwd $EXPECT/pwd\n" "" ""
197 testing '${x#prefix}' 'x=abcde; echo ${x#abc}' 'de\n' '' ''
198 testing '${x#short} ${x##long}' 'x=banana; echo ${x#b*n} ${x##b*n}' \
200 toyonly testing '${x#utf8}' 'x=aそcde; echo ${x##a?c}' 'de\n' '' ''
201 testing '${x%y}' 'x=potato; echo ${x%t*o} ${x%%t*o}' 'pota po\n' '' ''
202 testing '${x^y}' 'x=aaaaa; echo ${x^a}' 'Aaaaa\n' '' ''
203 testing '${x^^y}' 'x=abccdec; echo ${x^^c}; x=abcdec; echo ${x^^c}' \
205 testing '${x,y}' 'x=BBB; echo ${x,B}' 'bBB\n' '' ''
206 testing '${x,,y}' 'x=POTATO; echo ${x,,} ${x,,?} ${x,,*} ${x,,T}' \
211 testing 'wildcards' 'echo w[v-x]w w[x-v]w abc/*/ghi' \
214 #testing "backtick1" 'X=fred; echo `echo $x`' 'fred\n' "" ""
215 #testing "backtick2" 'X=fred; echo `x=y; echo $x`' 'y\n' "" ""
216 testing '$(( ) )' 'echo ab$((echo hello) | tr e x)cd' "abhxllocd\n" "" ""
217 testing '$((x=y)) lifetime' 'a=boing; echo $a $a$((a=4))$a $a' 'boing boing44 4\n' '' ''
219 testing 'quote' "echo \"'\"" "'\n" "" ""
222 …ng "case" 'for i in A C J B; do case "$i" in A) echo got A ;; B) echo and B ;; C) echo then C ;; *…
224 testing 'case;;&' 'case wow in w?w) echo ok;;& wow) echo no; esac' 'ok\nno\n' \
227 $'case i\n\nin\n\na) echo one\n\n;;\n\ni)\n\necho two\n\n;;\n\nesac' \
230 'false && for i in a b c; do echo $i; done || echo no' 'no\n' '' ''
231 testing "continue" 'for i in a b c; do for j in d e f; do echo $i $j; continue 2; done; done' \
234 'while X=$(($X+1)); do echo $X; done | while read i; do echo $i; done | head -n 5' \
239 testing "expand" 'echo $PWD' "$(pwd)\n" "" ""
240 testing "expand2" 'echo "$PWD"' "$(pwd)\n" "" ""
241 testing "expand3" 'echo "$"PWD' '$PWD\n' "" ""
242 testing "expand4" 'P=x; echo "$P"WD' 'xWD\n' "" ""
243 testing "dequote" "echo one 'two' ''three 'fo'ur '\\'" \
246 testing "leading variable assignment" 'abc=def env | grep ^abc=; echo $abc' \
249 "abc=def ghi=jkl env | egrep '^(abc|ghi)=' | sort; echo \$abc \$ghi" \
252 'abc=def; abc=ghi echo $abc' "def\n" "" ""
253 testing "leading assignment space" 'X="abc def"; Y=$X; echo "$Y"' \
256 'chicken() { X="$@"; }; chicken a b c d e; echo "$X"' 'a b c d e\n' '' ''
258 "{ 1blah=123 echo hello;} 2>/dev/null || echo no" "no\n" "" ""
260 "blah=123 echo hello > walrus && ls walrus" "walrus\n" "" ""
263 testing "{1..5}" "echo {1..5}" "1 2 3 4 5\n" "" ""
264 testing "{5..1}" "echo {5..1}" "5 4 3 2 1\n" "" ""
265 testing "{5..1..2}" "echo {5..1..2}" "5 3 1\n" "" ""
266 testing "{a..z..-3}" "echo {a..z..-3}" "a d g j m p s v y\n" "" ""
270 '{ sed s/ll/xx/ POIT; }& echo hello > POIT; wait' 'hexxo\n' '' ''
277 #$ IFS=x X=xyxz; for i in abc${X}def; do echo =$i=; done
283 … for i in $A $B $C $D L$A L$B L$C L$D $A= $B= $C= $D= L$A= L$B= L$C= L$D=; do echo -n {$i}; done' \
286 'A=" abc def "; for i in ""$A""; do echo =$i=; done' \
289 'A=" abc def "; for i in """"$A""; do echo =$i=; done' \
292 'A=" abc def "; for i in ""x""$A""; do echo =$i=; done' \
295 testing "IFS" 'IFS=x; A=abx; echo -n "$A"' "abx" "" ""
296 testing "IFS2" 'IFS=x; A=abx; echo -n $A' "ab" "" ""
297 testing "IFS3" 'IFS=x; echo "$(echo abx)"' "abx\n" "" ""
298 testing "IFS4" 'IFS=x; echo $(echo abx)y' "ab y\n" "" ""
299 testing "IFS5" 'IFS=xy; for i in abcxdefyghi; do echo =$i=; done' \
302 testing 'empty $! is blank' 'echo $!' "\n" "" ""
303 testing '$! = jobs -p' 'true & [ $(jobs -p) = $! ] && echo yes' "yes\n" "" ""
305 testing '$*' 'cc(){ for i in $*;do echo =$i=;done;};cc "" "" "" "" ""' \
307 testing '$*2' 'cc(){ for i in "$*";do echo =$i=;done;};cc ""' \
310 'cc(){ for i in "$*";do echo =$i=;done;};cc "" ""' "= =\n" "" ""
312 'cc() { echo ="$*"=; for i in =$*=; do echo -$i-; done;}; cc "" ""; echo and; cc ""' \
314 testing 'really?' 'cc() { for i in $*; do echo -$i-; done;}; cc "" "" ""' \
316 testing 'Sigh.' 'cc() { echo =$1$2=;}; cc "" ""' "==\n" "" ""
317 testing '$*4' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "" "" "" ""' \
319 testing '$*5' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "abc" ""' \
324 'IFS=x; cc(){ for i in $*; do echo =$i=;done;};cc xabcxx' \
326 testing '$@' 'cc(){ for i in "$@";do echo =$i=;done;};cc "" "" "" "" ""' \
328 testing "IFS10" 'IFS=bcd; A=abcde; for i in $A; do echo =$i=; done' \
331 'IFS=x; chicken() { for i in $@$@; do echo =$i=; done;}; chicken one "" abc dxf ghi' \
333 testing "IFS12" 'IFS=3;chicken(){ return 3;}; chicken;echo 3$?3' '3 3\n' "" ""
336 … for i in $A $B $C $D L$A L$B L$C L$D $A= $B= $C= $D= L$A= L$B= L$C= L$D=; do echo -n {$i}; done' \
339 testing "! isn't special" "echo !" "!\n" "" ""
340 testing "! by itself" '!; echo $?' "1\n" "" ""
341 testing "! true" '! true; echo $?' "1\n" "" ""
342 testing "! ! true" '! ! true; echo $?' "0\n" "" ""
343 testing "! syntax err" '! echo 2>/dev/null < doesnotexist; echo $?' "0\n" "" ""
346 testing "case quoting" 'case a in "a") echo hello;; esac' 'hello\n' "" ""
348 testing "subshell splitting" 'for i in $(true); do echo =$i=; done' "" "" ""
352 testing "assignment nosplit" 'X="one two"; Y=$X; echo $Y' "one two\n" "" ""
354 'chicken() { for i in a"$@"b;do echo =$i=;done;}; chicken 123 456 789' \
356 testing "assignment nosplit2" 'pop(){ X="$@";};pop one two three; echo $X' \
360 # 'VAR=12345 echo ${VAR}a' "a\n" "" ""
362 # 'BLAH=abcdefghi; echo ${BLAH: 1 : 3 }' "bcd\n" "" ""
364 testing "subshell exit err" '(exit 42); echo $?' "42\n" "" ""
367 #testing 'exec and $$' testing 'echo $$;exec readlink /proc/self'
371 '(exec readlink /proc/self/exe);echo hello' "$X\nhello\n" "" ""
373 "{ exec readlink /proc/self/exe;};echo hi" "$X\n" "" ""
376 '{ echo one; echo two ; } | tee blah.txt; wc blah.txt' \
379 '(echo two;echo three)|tee blah.txt;wc blah.txt' \
382 'echo hello | (read i <input; echo $i; read i; echo $i)' \
385 testing "\$''" $'echo $\'abc\\\'def\\nghi\'' "abc'def\nghi\n" '' ''
386 testing "shift shift" 'shift; shift; shift; echo $? hello' "1 hello\n" "" ""
387 testing 'search cross $*' 'chicken() { echo ${*/b c/ghi}; }; chicken a b c d' \
389 testing 'eval $IFS' 'IFS=x; X=x; eval abc=a${X}b 2>/dev/null; echo $abc' \
391 testing '${@:3:5}' 'chicken() { for i in "${@:3:5}"; do echo =$i=; done; } ; chicken ab cd ef gh ij…
393 testing '${@:3:5}' 'chicken() { for i in "${*:3:5}"; do unset IFS; echo =$i=; done; } ; IFS=x chick…
395 testing 'sequence check' 'IFS=x; X=abxcd; echo ${X/bxc/g}' 'agd\n' '' ''
398 #txpect "backtick0" "$SS" "E$P" 'IX=fred; echo `echo \\\\$x`'$'\n' 'Ofred' "E$P" X0
399 #txpect "backtick1" "$SS" "E$P" 'IX=fred; echo `echo $x`'$'\n' 'Ofred'$'\n' "E$P" X0
400 #txpect "backtick2" "$SS" "E$P" 'IX=fred; echo `x=y; echo $x`' $'Oy\n' "E$P" X0
402 shxpect '${ with newline' I$'HELLO=abc; echo ${HELLO/b/\n' E"> " I$'}\n' O$'a c\n'
411 testing '${var}' 'X=abcdef; echo ${X}' 'abcdef\n' '' ''
412 testing '${#}' 'X=abcdef; echo ${#X}' "6\n" "" ""
413 testing 'empty ${}' '{ echo ${};} 2>&1 | grep -o bad' 'bad\n' '' ''
414 shxpect 'empty ${} syntax err abort' I$'echo ${}; echo hello\n' \
415 E I$'echo and\n' O$'and\n'
416 testing '${$b}' '{ echo ${$b};} 2>&1 | grep -o bad' 'bad\n' '' ''
417 testing '${!PATH*}' 'echo ${!PATH*}' 'PATH\n' '' ''
418 testing '${!PATH@}' 'echo ${!PATH@}' 'PATH\n' '' ''
419 #testing '${!PATH[@]}' 'echo ${!PATH[@]}' '0\n' '' ''
420 testing '${!x}' 'X=abcdef Y=X; echo ${!Y}' 'abcdef\n' '' ''
421 testing '${!x@}' 'ABC=def; def=ghi; echo ${!ABC@}' 'ABC\n' '' ''
422 testing '${!x} err' '{ X=abcdef Y=X:2; echo ${!Y}; echo bang;} 2>/dev/null' \
424 testing '${!x*}' 'abcdef=1 abc=2 abcq=; echo "${!abc@}" | tr " " \\n | sort' \
426 testing '${!x*} none' 'echo "${!abc*}"' '\n' '' ''
427 testing '${!x*} err' '{ echo "${!abc*x}"; echo boing;} 2>/dev/null' '' '' ''
428 testing '${!none@Q}' 'echo ${X@Q} ${!X@Q}; X=ABC; echo ${!X@Q}' '\n\n' '' ''
429 testing '${!x@Q}' 'ABC=123 X=ABC; echo ${!X@Q}' "'123'\n" '' ''
430 testing '${#@Q}' 'echo ${#@Q}' "'0'\n" '' ''
431 testing '${!*}' 'xx() { echo ${!*};}; fruit=123; xx fruit' '123\n' '' ''
432 testing '${!*} indirect' 'xx() { echo ${!a@Q};}; a=@; xx one two three' \
435 '{ ABC=def; def=ghi; echo ${!ABC@ }; } 2>&1 | grep -o bad' 'bad\n' '' ''
436 testing '${!x@ } no match no err' 'echo ${!ABC@ }def' 'def\n' '' ''
437 testing '${!x@ } no match no err2' 'ABC=def; echo ${!ABC@ }ghi' 'ghi\n' '' ''
438 toyonly testing '${#x::}' 'ABC=abcdefghijklmno; echo ${#ABC:1:2}' '5\n' '' ''
440 testing '$""' 'ABC=def; echo $"$ABC"' 'def\n' '' ''
441 testing '"$""" does not nest' 'echo "$"abc""' '$abc\n' '' ''
442 testing '${\}}' 'ABC=ab}cd; echo ${ABC/\}/x}' 'abxcd\n' '' ''
443 testing 'bad ${^}' '{ echo ${^};} 2>&1 | grep -o bad' 'bad\n' '' ''
444 testing '${:}' 'ABC=def; echo ${ABC:1}' 'ef\n' '' ''
445 testing '${a: }' 'ABC=def; echo ${ABC: 1}' 'ef\n' '' ''
446 testing '${a :}' 'ABC=def; { echo ${ABC :1};} 2>&1 | grep -o bad' 'bad\n' '' ''
447 testing '${::}' 'ABC=defghi; echo ${ABC:1:2}' 'ef\n' '' ''
448 testing '${: : }' 'ABC=defghi; echo ${ABC: 1 : 2 }' 'ef\n' '' ''
449 testing '${::} indirect' 'ABC=defghi:1:2; { echo ${!ABC};} 2>&1 | grep -o bad' \
451 testing '${::-}' 'ABC=defghi; echo ${ABC:1:-2}' 'efg\n' '' ''
452 testing '${:-:-}' 'ABC=defghi; echo ${ABC:-3:2}' 'defghi\n' '' ''
453 testing '${:-:-}2' 'echo ${ABC:-3:2}' '3:2\n' '' ''
454 testing '${: -:}' 'ABC=defghi; echo ${ABC: -3:2}' 'gh\n' '' ''
455 testing '${@%}' 'chicken() { for i in "${@%abc}"; do echo "=$i="; done;}; chicken 1abc 2abc 3abc' '…
456 testing '${*%}' 'chicken() { for i in "${*%abc}"; do echo "=$i="; done;}; chicken 1abc 2abc 3abc' '…
457 testing '${@@Q}' 'xx() { echo "${@@Q}"; }; xx one two three' \
460 shxpect '${/newline/}' I$'x=$\'\na\';echo ${x/\n' E'> ' I$'/b}\n' O$'ba\n' E'> '
462 shxpect 'line continuation' I$'echo "hello" \\\n' E'> ' I$'> blah\n' E"$P" \
464 shxpect 'line continuation2' I$'echo ABC\\\n' E'> ' I$'DEF\n' O$'ABCDEF\n'
467 testing 'SECONDS' 'readonly SECONDS=41; sleep 1; echo $SECONDS' '42\n' '' ''
468 # testing 'SECONDS2' 'readonly SECONDS; SECONDS=0; echo $SECONDS' '' '' '' #bash!
469 testing 'SECONDS2' 'SECONDS=123+456; echo $SECONDS' '0\n' '' '' #bash!!
470 testing '$LINENO 2' $'echo $LINENO\necho $LINENO' '0\n1\n' '' ''
471 testing '$EUID' 'echo $EUID' "$(id -u)\n" '' ''
472 testing '$UID' 'echo $UID' "$(id -ur)\n" '' ''
475 '{ readonly abc=123;abc=def echo hello; echo $?;} 2>output; grep -o readonly output' \
478 …'readonly boink=123; export boink; { boink=234 env | grep ^boink=;} 2>/dev/null; echo $?' 'boink=1…
480 'readonly i; for i in one two three; do echo $i; done 2>/dev/null; echo $?' \
483 'readonly i; echo hello 2>/dev/null {i}</dev/null; echo $?' '1\n' '' ''
484 testing '$_ 1' 'echo walrus; echo $_' 'walrus\nwalrus\n' '' ''
485 testing '$_ 2' 'unset _; echo $_' '_\n' '' ''
491 'IFS=xy; ABC=abcywal*sxdef; echo $ABC | tr " " "\n" | sort' \
498 I$'IFS=x; ABC=cxd; for i in +($ABC); do echo =$i=; done\n' \
503 I$'ABC="c?d"; for i in ab+($ABC); do echo =$i=; done\n' \
508 I$'touch "AB[DEF]"; echo AB[+(DEF]) AB[+(DEF)? AB+([DEF)]\n' \
510 I$'X="("; Y=")"; echo AB[+${X}DEF${Y}?\n' O$'AB[DEF]\n'
512 # TODO: syntax error takes out ': ${a?b}; echo $?' (I.E. never runs echo)
514 I$': ${a?b} ${c:=d}\n' E E"$P" I$'echo $?$c\n' O$'1\n'
516 shxpect 'trace redirect' I$'set -x; echo one\n' E$'+ echo one\n'"$P" O$'one\n' \
517 I$'echo two 2>/dev/null\n' O$'two\n' E$'+ echo two\n'"$P" \
518 I$'{ echo three; } 2>/dev/null\n' O$'three\n' E"$P"
520 testing 'source file' 'source input' 'hello\n' 'echo hello \\\n' ''
521 testing '. file' '. input' 'hello\n' 'echo hello \\\n' ''
522 testing 'source no newline' 'source input' 'hello \\\n' 'echo hello \\' ''
524 'for i in one two three; do echo "echo $i" > input; source input; done' \
527 'func() { source input; }; for i in one two three; do echo echo $i > input; func; done' \
530 …'func() { source input; cat <(echo $xx; xx=456; echo $xx); echo $xx;}; echo local xx=123 > input; …
533 'source input 2>/dev/null || echo yes' 'one\nyes\n' \
534 'echo one\necho two; echo |' ''
536 …'func() { echo one; source <(echo -e "echo hello\necho |") 2>/dev/null; echo three;}; func; echo f…
539 'func() { eval "echo one; echo \${?potato}; echo and" 2>/dev/null; echo plus;}; func; echo then' \
543 '{ echo $BASHPID; chicken() { echo $BASHPID;}; chicken;} | sort -u | wc -l' '1\n' '' ''
545 '{ echo $BASHPID; chicken() ( echo $BASHPID;); chicken;} | sort -u | wc -l' '2\n' '' ''
547 'func() if true; then echo hello; fi; echo one; func; echo two' \
550 I$'func() { local potato; echo ${potato?bang}; }; potato=123; func\n' \
551 E E"$P" I$'echo $?\n' O$'1\n'
557 # ./bash -c 'echo $_' prints $BASH, but PATH search shows path? Hmmm...
587 # does not match: ./sh -c 'echo {a..Z}' becomes a ` _ ^ ] \ [ Z