1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-07-26 02:30:35 +02:00

tests: remove use of unprotected 'set'

* cfg.mk (sc_prohibit_bare_set): A new syntax check to
ensure we protect use of set with '--', so that args
beginning with '-' are not interpreted as options,
and if no args are present, all existing args are cleared.
* tests/cp/symlink-slash.sh: Add -- to unprotected use of set.
* tests/ls/ls-time.sh: Likewise.
* tests/ls/symlink-slash.sh: Likewise.
* tests/mkdir/perm.sh: Likewise.
* tests/mkdir/selinux.sh: Likewise.
* tests/mkdir/smack-no-root.sh: Likewise.
* tests/mkdir/smack-root.sh: Likewise.
* tests/mv/part-hardlink.sh: Likewise.
* tests/nice/nice.sh: Likewise.
* tests/stty/stty-row-col.sh: Likewise.
This commit is contained in:
Pádraig Brady
2025-01-20 15:21:58 +00:00
parent e6117526c3
commit dcc896e6c3
11 changed files with 24 additions and 18 deletions
+6
View File
@@ -498,6 +498,12 @@ sc_prohibit_NULL:
halt='use nullptr instead' \
$(_sc_search_regexp)
sc_prohibit_bare_set:
@prohibit='^ *set [`$$]' \
in_vc_files='\.sh$$' \
halt='use set -- $$args instead of set $$args' \
$(_sc_search_regexp)
# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
sc_prohibit_emacs__indent_tabs_mode__setting:
@prohibit='^( *[*#] *)?indent-tabs-mode:' \
+1 -1
View File
@@ -24,7 +24,7 @@ mkdir dir || framework_failure_
ln -s dir symlink || framework_failure_
cp -dR symlink/ s || fail=1
set $(ls -l s)
set -- $(ls -l s)
# Prior to fileutils-4.0q, the following would have output ...'s -> dir'
# because the trailing slash was removed unconditionally (now you have to
+8 -8
View File
@@ -38,7 +38,7 @@ touch -m -d "$t1" c || framework_failure_
# Check default name sorting works
for def_sort in '' '--sort=name' '-U --sort=name' '-t --sort=name'; do
set $(ls $def_sort a B c)
set -- $(ls $def_sort a B c)
test "$*" = 'B a c' || fail=1
done
@@ -53,9 +53,9 @@ touch -a -d "$u1" a || framework_failure_
# A has ctime more recent than C.
set $(ls -t -c a c)
set -- $(ls -t -c a c)
test "$*" = 'a c' || fail=1
set $(ls -c a c) # Not specified by POSIX
set -- $(ls -c a c) # Not specified by POSIX
test "$*" = 'a c' || fail=1
# Sleep so long in an attempt to avoid spurious failures
@@ -101,20 +101,20 @@ EOF
;;
esac
set $(ls -ut a B c)
set -- $(ls -ut a B c)
test "$*" = 'c B a' || fail=1
set $(ls -u a B c) # not specified by POSIX
set -- $(ls -u a B c) # not specified by POSIX
test "$*" = 'c B a' || fail=1
test $fail = 1 && ls -l --full-time --time=access a B c
set $(ls -t a B c)
set -- $(ls -t a B c)
test "$*" = 'a B c' || fail=1
set $(ls --time=mtime a B c)
set -- $(ls --time=mtime a B c)
test "$*" = 'a B c' || fail=1
test $fail = 1 && ls -l --full-time a B c
# Now, C should have ctime more recent than A.
set $(ls -ct a c)
set -- $(ls -ct a c)
if test "$*" = 'c a'; then
: ok
else
+1 -1
View File
@@ -22,7 +22,7 @@ print_ver_ ls
mkdir dir || framework_failure_
ln -s dir symlink || framework_failure_
set $(ls -l symlink/)
set -- $(ls -l symlink/)
# Prior to fileutils-4.0k, the following would have output '... symlink -> dir'.
test "$*" = 'total 0' && : || fail=1
+1 -1
View File
@@ -47,7 +47,7 @@ for p in empty -p; do
old_IFS=$IFS
IFS=':'
set $colon_tests
set -- $colon_tests
IFS=$old_IFS
while :; do
+1 -1
View File
@@ -33,7 +33,7 @@ for cmd_w_arg in 'mkdir dir' 'mknod b p' 'mkfifo f'; do
# In OpenBSD's /bin/sh, mknod is a shell built-in.
# Running via "env" ensures we run our program and not the built-in.
env -- $cmd_w_arg --context=$c 2> out && fail=1
set $cmd_w_arg; cmd=$1
set -- $cmd_w_arg; cmd=$1
echo "$cmd: $msg" > exp || framework_failure_
# Some systems fail with ENOTSUP, EINVAL, ENOENT, or even
+1 -1
View File
@@ -28,7 +28,7 @@ msg="failed to set default file creation context to '$c':"
for cmd in 'mkdir dir' 'mknod b p' 'mkfifo f'; do
$cmd --context="$c" 2> out && fail=1
set $cmd
set -- $cmd
echo "$1: $msg" > exp || framework_failure_
sed -e 's/ Operation not permitted$//' out > k || framework_failure_
+1 -1
View File
@@ -28,7 +28,7 @@ c=arbitrary-smack-label
for cmd in 'mkdir dir' 'mknod b p' 'mkfifo f'; do
$cmd --context="$c" || { fail=1; continue; }
set $cmd
set -- $cmd
ls -dZ $2 > out || fail=1
test "$(cut -f1 -d' ' out)" = "$c" || { cat out; fail=1; }
done
+2 -2
View File
@@ -35,9 +35,9 @@ mv f g "$other_partition_tmpdir" || fail=1
mv a b "$other_partition_tmpdir" || fail=1
cd "$other_partition_tmpdir"
set $(ls -Ci f g)
set -- $(ls -Ci f g)
test $1 = $3 || fail=1
set $(ls -Ci a/1 b/1)
set -- $(ls -Ci a/1 b/1)
test $1 = $3 || fail=1
Exit $fail
+1 -1
View File
@@ -42,7 +42,7 @@ tests='
19 --1:-12 12
NA LAST NA
'
set $tests
set -- $tests
# Require that this test be run at 'nice' level 0.
niceness=$(nice)
+1 -1
View File
@@ -53,7 +53,7 @@ tests='
11 rows_036 30_80
NA LAST NA
'
set $tests
set -- $tests
saved_size=$(stty size) && test -n "$saved_size" \
|| skip_ "can't get window size"