1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# The few places where omitting quotes is ok
# Not that I like exceptions, but legal is legal.
# See "Where you can omit the double quotes":
# https://unix.stackexchange.com/a/68748
# Assignments
asterisk=$(echo '*')
spacestar=$IFS
spacestar+=$asterisk
a=(a b)
b=${a[@]}
c=$*
pwd=`pwd`hazard
# In the case expression
case $spacestar in
$' \t\n*')
echo pass
;;
*)
echo fail
;;
esac
case $(printf ' \t\n*') in
$' \t\n*')
echo pass
;;
*)
echo fail
;;
esac
# Case arms
case $' \t\n*' in
$spacestar)
echo pass
;;
*)
echo fail
;;
esac
case $' \t\n*' in
$(printf ' \t\n*'))
echo pass
;;
*)
echo fail
;;
esac
# Double brackets
if [[ ${a[@]} == ${b[@]} ]]; then
echo pass
else
echo fail
fi
# Numeric content
echo $? + $# - ${#a[@]} = $(($?+$#-${#a[@]}))
# Let's allow backticks where they don't hurt
a=`uname -a`
# Counterexamples
pwd=$PWD; case $PWD in esac
pwd=$PWD
pwd+=$PWD
files=("$(ls)")
files+=("$(ls)")