slitaz-base-files view test-libtaz.sh @ rev 294
Makefile: escape $
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Dec 31 11:55:04 2015 +0200 (2015-12-31) |
parents | |
children | 65248d132cd2 |
line source
1 #!/bin/sh
2 #
3 . rootfs/lib/libtaz.sh
5 [ $# -eq 0 ] && title 'Check variables import using libtaz.sh'
7 if [ "$1" == 'test' ]; then env; exit 0; fi
9 ME=$(realpath $0); n=/tmp/n; echo 1 > $n; tests=18
11 t() {
12 i=$(cat $n)
13 printf "%2d/%d: %-16s: test %s" "$i" "$tests" "$1" "$2 $3" >&2
14 $ME test "$2" "$3"
15 echo $((i + 1)) > $n
16 }
18 t 'without dashes' install | grep -qv '^install='; status
19 t 'single dash' -install | grep -qv '^install='; status
20 t 'with dashes' --install | grep -q '^install=yes$'; status
21 t 'empty 1' --install= | grep -q '^install=$'; status
22 t 'non-empty' --install=value | grep -q '^install=value$'; status
23 t 'single quotes' --install='value' | grep -q '^install=value$'; status
24 t 'double quotes' --install="value" | grep -q '^install=value$'; status
25 t 'double "=" 1' --install=all=true | grep -q '^install=all=true$'; status
26 t 'double "=" 2' --install==double | grep -q '^install==double$'; status
27 t 'spaces 1' --install="a bb ccc" | grep -q '^install=a bb ccc$'; status
28 t 'spaces 2' --install=a\ bb\ \ ccc | grep -q '^install=a bb ccc$'; status
29 t 'start with digit' --7zip | grep -q '^_7zip=yes$'; status
30 t 'extra dashes 1' ----install | grep -q '^__install=yes$'; status
31 t 'extra dashes 2' --ins--tall | grep -q '^ins__tall=yes$'; status
32 t 'extra dashes 3' --ins-tall | grep -q '^ins_tall=yes$'; status
33 t 'extra dashes 4' --ins-tall=ins-tall | grep -q '^ins_tall=ins-tall$'; status
34 t 'repeated' --abc=1 --abc=2 | grep -q '^abc=2$'; status
35 t 'dollar sign' --a\$bc=a\$bc | grep -q '^a_bc=a\$bc$'; status
37 footer 'Tests completed'
38 rm $n