blob: 84098f7c49a6bd0722c9b20b41ee461101e16142 (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
#!/bin/sh
set -e
cat <<EOF
This is all really bad bash specific code!!!
read
source /bar/baz/bat foo
EOF
# ok, back to checking
if [ "$2" == "purge" ]; then
rm -r /bar/baz
fi
function foo( ) {
# but not here: local
local bar
echo "foo" &>/dev/null
}
source $FOO
trap "echo hi" EXIT HUP 3
if [[ "$2" = "purge" ]]; then
kill -HUP $$
fi
#this is ok though
if test -n $(echo foo | perl -pe 's/[[:space:]]//go'); then
echo 1
fi
# More false positives for bashism checks. None of these are errors.
echo "$line" | grep -q '{fonts/map,}/{\$progname,pdftex,dvips,}//'
echo "$line" | grep -q "${fonts},${foo}"
echo '$[1+2]'
printf "foo |& bar"
perl -e "print q( kill -HUP $? )"
# Still catch disallowed expansions in double-quotes, though.
echo "${line:3:1}"
# More bashisms checks
read -x foo
read -x
read -r foo
read foo
read
echo "a\\b"
echo 'a\nb'
echo "${UID}"
echo "$EUID"
echo "$SHLVL"
echo "$DIRSTACK"
echo "$SECONDS"
echo "$BASH"
echo "$BASH_FOO"
echo "$SHELLOPTS"
echo "$PIPESTATUS"
bar="$(cut '-d|' -f2 <<< "$foo")"
VAR=1
VAR+=a
echos() {
echo -n -e "bar"
echo -e -n "bar"
echo -en "bar"
echo -ne "bar"
echo "bar"
echo "echo -e foo"
}
ech.os() {
echo foo >& 2
echo foo >&bar
echo foo >& bar
}
echoes() {
echo "abc\nxyz"
echo 'xyz\rabc'
echo foo\cbar
echo -e "abc\nxyz"
echo -net 'xyz\rabc'
echo -e foo\cbar
}
foobar.() {
suspend x
suspended x
caller x
complete x
compgen x
declare -a foo
}
.foobar() {
typeset -x bar
disown 1
builtin foo
set -B
alias -p
unalias -a
}
IFS="()"
ulimit
shopt
type -v bar
time ls
dirs
diff <(tac a) <(tac b)
pushd
local foo=bar
local -x foo
popd
readonly -f
echo bar > /dev/tcp
export x
export -x x
export -p x
sh -x
sh -D
sh --foo
sh +O
# Brace expansion checks
echo {a,b}
echo {abc},{bcd}
foobar()
{
# This is a function
}
foo.bar()
(
# This is a function with a bad name
)
foobar@() # foo
{
# As is this
}
# This is ok
read -r foo
# but these aren't
read -r
read -p "Would you like to restart the service?" foo bar
read --fish
source "$BAR"
source '$BAR'
source ~/bar
source a
# An example from the X maintainer scripts that used to trigger the trap
# bashism check.
trap "message;\
message \"Received signal. Aborting $THIS_PACKAGE package $THIS_SCRIPT script.\";\
message;\
exit 1" HUP INT QUIT TERM
# Also allow for extended single quotes containing double quotes.
trap 'message;
message "Received signal. Aborting $THIS_PACKAGE package $THIS_SCRIPT script.";
message;
exit 1' HUP INT QUIT TERM
#DEBHELPER#
|