Skip to content

Commit ba130d6

Browse files
authored
Merge pull request #116 from alexharv074/alexharvey/protect_sed_command
Also protect sed command
2 parents f7e00b4 + 6d17127 commit ba130d6

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

shunit2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ _shunit_mktempDir() {
902902
# shellcheck disable=SC2039
903903
if command [ -r '/dev/urandom' -a -x '/usr/bin/od' ]; then
904904
_shunit_random_=`/usr/bin/od -vAn -N4 -tx4 </dev/urandom \
905-
|sed 's/^[^0-9a-f]*//'`
905+
|command sed 's/^[^0-9a-f]*//'`
906906
elif command [ -n "${RANDOM:-}" ]; then
907907
# $RANDOM works
908908
_shunit_random_=${RANDOM}${RANDOM}${RANDOM}$$
@@ -1203,7 +1203,7 @@ _shunit_escapeCharInStr() {
12031203

12041204
# Escape the character.
12051205
# shellcheck disable=SC1003,SC2086
1206-
echo ''${_shunit_s_}'' |sed 's/\'${_shunit_c_}'/\\\'${_shunit_c_}'/g'
1206+
echo ''${_shunit_s_}'' |command sed 's/\'${_shunit_c_}'/\\\'${_shunit_c_}'/g'
12071207

12081208
unset _shunit_c_ _shunit_s_
12091209
}
@@ -1243,7 +1243,7 @@ _shunit_extractTestFunctions() {
12431243
_shunit_regex_='^\s*((function test[A-Za-z0-9_-]*)|(test[A-Za-z0-9_-]* *\(\)))'
12441244
# shellcheck disable=SC2196
12451245
egrep "${_shunit_regex_}" "${_shunit_script_}" \
1246-
|sed 's/^[^A-Za-z0-9_-]*//;s/^function //;s/\([A-Za-z0-9_-]*\).*/\1/g' \
1246+
|command sed 's/^[^A-Za-z0-9_-]*//;s/^function //;s/\([A-Za-z0-9_-]*\).*/\1/g' \
12471247
|xargs
12481248

12491249
unset _shunit_regex_ _shunit_script_

shunit2_misc_test.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,8 @@ EOF
249249
}
250250

251251
# Test that certain external commands sometimes "stubbed" by users are escaped.
252-
# See Issue #54.
253-
testProtectedCommands() {
254-
for c in mkdir rm cat chmod; do
252+
testIssue54() {
253+
for c in mkdir rm cat chmod sed; do
255254
grep "^[^#]*${c} " "${TH_SHUNIT}" | grep -qv "command ${c}"
256255
assertFalse "external call to ${c} not protected somewhere" $?
257256
done

0 commit comments

Comments
 (0)