diff options
author | Rob Landley <rob@landley.net> | 2020-10-11 02:59:54 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-10-11 02:59:54 -0500 |
commit | 67bd0be1a4ed817954c9dcededf9bd9cb8c2f431 (patch) | |
tree | 4df0aa1044af467469e77c757bbf58dffe2f6178 /tests | |
parent | 0f2658c806586190be3aca21826e77fff9e50f1b (diff) | |
download | toybox-67bd0be1a4ed817954c9dcededf9bd9cb8c2f431.tar.gz |
toysh: more variable/wildcard plumbing and tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/sh.test | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/sh.test b/tests/sh.test index f0764858..b095bb95 100644 --- a/tests/sh.test +++ b/tests/sh.test @@ -1,5 +1,9 @@ #!/bin/echo no +# TODO https://mywiki.wooledge.org/BashFAQ +# http://tiswww.case.edu/php/chet/bash/FAQ +# https://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail + # // ${#} ${#x} ${#@} ${#x[@]} ${#!} ${!#} # // ${!} ${!@} ${!@Q} ${!x} ${!x@} ${!x@Q} ${!x#} ${!x[} ${!x[*]} @@ -169,10 +173,15 @@ testing '${x#prefix}' 'x=abcde; echo ${x#abc}' 'de\n' '' '' testing '${x#short} ${x##long}' 'x=banana; echo ${x#b*n} ${x##b*n}' \ 'ana a\n' '' '' toyonly testing '${x#utf8}' 'x=aそcde; echo ${x##a?c}' 'de\n' '' '' +mkdir -p abc/def/ghi +touch www +testing 'wildcards' 'echo w[v-x]w w[x-v]w abc/*/ghi' \ + 'www w[x-v]w abc/def/ghi\n' '' '' #testing "backtick1" 'X=fred; echo `echo $x`' 'fred\n' "" "" #testing "backtick2" 'X=fred; echo `x=y; echo $x`' 'y\n' "" "" testing '$(( ) )' 'echo ab$((echo hello) | tr e x)cd' "abhxllocd\n" "" "" +testing '$((x=y)) lifetime' 'a=boing; echo $a $a$((a=4))$a $a' 'boing boing44 4\n' '' '' # Loops and flow control testing "case" 'for i in A C J B; do case "$i" in A) echo got A ;; B) echo and B ;; C) echo then C ;; *) echo default ;; esac; done' \ |