Skip to contentSkip to conversation

fstests: which has been deprecated by Debian

PATCH In review Dave Chinner 4 participants 6 messages Aug 30, 2021 – Sep 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fstests: which has been deprecated by Debian

From: Dave Chinner <[email protected]>

This patch is brought to you by the Department That Hates Users.

The latest debian unstable release is now causing a bunch of new test failures because they have deprecated the which command.

Rather than make everyone jump through hoops chasing problems with 'which' while debian decides to how to package at least three variants of 'which' - each which will different semantics, behaviour and support - as alternatives users then have to opt into, let's just remove the remaining uses of the shell independent 'which' command and replace them with bash builtin 'type -P' operations.

---
 common/rc         | 2 +-
 src/fill2fs       | 2 +-
 tests/ext4/006    | 2 +-
 tests/generic/128 | 2 +-
 tests/generic/452 | 2 +-
 tests/xfs/293     | 2 +-
 tests/xfs/505     | 2 +-
 tests/xfs/514     | 2 +-
 tests/xfs/515     | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)
common/rc +1 -1
index a7f9ed86..db400c4d 100644
@@ -4,7 +4,7 @@
 
 . common/config
 
-BC=$(which bc 2> /dev/null) || BC=
+BC="$(type -P bc)" || BC=
 
 _require_math()
 {
src/fill2fs +1 -1
index 1c3383a8..d5e5436b 100755
@@ -111,7 +111,7 @@ sub normal {
 #
 
 chomp($cwd = `pwd`);
-chomp($_ = `which fill2 2>&1 | head -1`);
+chomp($_ = `type -P fill2 | head -1`);
 if (-x $_) {
   # look in the path
   $fill2 = fill2;
tests/ext4/006 +1 -1
index 17e77f86..48ed6bee 100755
@@ -24,7 +24,7 @@ _cleanup()
 . ./common/populate
 . ./common/fuzzy
 
-if [ ! -x "$(which e2fuzz)" ]; then
+if [ ! -x "$(type -P e2fuzz)" ]; then
 	_notrun "Couldn't find e2fuzz"
 fi
 
tests/generic/128 +1 -1
index dfc67fd5..dc1d43f4 100755
@@ -23,7 +23,7 @@ _scratch_mkfs >/dev/null 2>&1
 _scratch_mount "-o nosuid"
 
 mkdir $SCRATCH_MNT/nosuid
-cp `which ls` $SCRATCH_MNT
+cp "$(type -P ls)" $SCRATCH_MNT
 chmod 700 $SCRATCH_MNT/nosuid
 chmod 4755 $SCRATCH_MNT/ls
 
tests/generic/452 +1 -1
index ee4dfe9e..7cbd2dfa 100755
@@ -26,7 +26,7 @@ _exclude_scratch_mount_option "noexec"
 _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
-LS=$(which ls --skip-alias --skip-functions)
+LS="$(type -P ls) --skip-alias --skip-functions)"
 SCRATCH_LS=$SCRATCH_MNT/ls_on_scratch
 cp $LS $SCRATCH_LS
 
tests/xfs/293 +1 -1
index fbd26b63..20f8c486 100755
@@ -30,7 +30,7 @@ case "$MANPAGE" in
 *)		CAT=cat;;
 esac
 
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_IO_PROG -c help | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
tests/xfs/505 +1 -1
index 8a999ff4..71fb6e9d 100755
@@ -26,7 +26,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_SPACEMAN_PROG -c help $TEST_DIR | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
tests/xfs/514 +1 -1
index a9c67645..cf5588f2 100755
@@ -34,7 +34,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 file=$TEST_DIR/xx.$seq
 truncate -s 128m $file
tests/xfs/515 +1 -1
index 32216fe6..2d7bbb35 100755
@@ -34,7 +34,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_QUOTA_PROG -x -c help $file | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
Signature · 1 line
2.31.1
#1 lore raw
Quoted 88 lines · Dave Chinner

From: Dave Chinner <[email protected]>

This patch is brought to you by the Department That Hates Users.

The latest debian unstable release is now causing a bunch of new test failures because they have deprecated the which command.

Rather than make everyone jump through hoops chasing problems with 'which' while debian decides to how to package at least three variants of 'which' - each which will different semantics, behaviour and support - as alternatives users then have to opt into, let's just remove the remaining uses of the shell independent 'which' command and replace them with bash builtin 'type -P' operations.

---

 common/rc         | 2 +-
 src/fill2fs       | 2 +-
 tests/ext4/006    | 2 +-
 tests/generic/128 | 2 +-
 tests/generic/452 | 2 +-
 tests/xfs/293     | 2 +-
 tests/xfs/505     | 2 +-
 tests/xfs/514     | 2 +-
 tests/xfs/515     | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)
common/rc +1 -1
index a7f9ed86..db400c4d 100644
@@ -4,7 +4,7 @@
 
 . common/config
 
-BC=$(which bc 2> /dev/null) || BC=
+BC="$(type -P bc)" || BC=
 
 _require_math()
 {
src/fill2fs +1 -1
index 1c3383a8..d5e5436b 100755
@@ -111,7 +111,7 @@ sub normal {
 #
 
 chomp($cwd = `pwd`);
-chomp($_ = `which fill2 2>&1 | head -1`);
+chomp($_ = `type -P fill2 | head -1`);
 if (-x $_) {
   # look in the path
   $fill2 = fill2;
tests/ext4/006 +1 -1
index 17e77f86..48ed6bee 100755
@@ -24,7 +24,7 @@ _cleanup()
 . ./common/populate
 . ./common/fuzzy
 
-if [ ! -x "$(which e2fuzz)" ]; then
+if [ ! -x "$(type -P e2fuzz)" ]; then
 	_notrun "Couldn't find e2fuzz"
 fi
 
tests/generic/128 +1 -1
index dfc67fd5..dc1d43f4 100755
@@ -23,7 +23,7 @@ _scratch_mkfs >/dev/null 2>&1
 _scratch_mount "-o nosuid"
 
 mkdir $SCRATCH_MNT/nosuid
-cp `which ls` $SCRATCH_MNT
+cp "$(type -P ls)" $SCRATCH_MNT
 chmod 700 $SCRATCH_MNT/nosuid
 chmod 4755 $SCRATCH_MNT/ls
 
tests/generic/452 +0 -0
index ee4dfe9e..7cbd2dfa 100755

tests/generic/452 _exclude_scratch_mount_option "noexec" · line 29

Quoted 5 lines
tests/generic/452 +1 -1
@@ -26,7 +26,7 @@ _exclude_scratch_mount_option "noexec"
 _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
-LS=$(which ls --skip-alias --skip-functions)
+LS="$(type -P ls) --skip-alias --skip-functions)"

I think the "--skip-alias" and "--skip-functions" options are belong to the "which" command, so this change might cause fail.

Thanks,
Zorro

Quoted 58 lines
tests/generic/452 +0 -0
 SCRATCH_LS=$SCRATCH_MNT/ls_on_scratch
 cp $LS $SCRATCH_LS
 
tests/xfs/293 +1 -1
index fbd26b63..20f8c486 100755
@@ -30,7 +30,7 @@ case "$MANPAGE" in
 *)		CAT=cat;;
 esac
 
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_IO_PROG -c help | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
tests/xfs/505 +1 -1
index 8a999ff4..71fb6e9d 100755
@@ -26,7 +26,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_SPACEMAN_PROG -c help $TEST_DIR | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
tests/xfs/514 +1 -1
index a9c67645..cf5588f2 100755
@@ -34,7 +34,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 file=$TEST_DIR/xx.$seq
 truncate -s 128m $file
tests/xfs/515 +1 -1
index 32216fe6..2d7bbb35 100755
@@ -34,7 +34,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_QUOTA_PROG -x -c help $file | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
Signature · 1 line
2.31.1
#2 lore raw
Quoted 92 lines · Zorro Lang
Quoted 91 lines · Dave Chinner

From: Dave Chinner <[email protected]>

This patch is brought to you by the Department That Hates Users.

The latest debian unstable release is now causing a bunch of new test failures because they have deprecated the which command.

Rather than make everyone jump through hoops chasing problems with 'which' while debian decides to how to package at least three variants of 'which' - each which will different semantics, behaviour and support - as alternatives users then have to opt into, let's just remove the remaining uses of the shell independent 'which' command and replace them with bash builtin 'type -P' operations.

---

 common/rc         | 2 +-
 src/fill2fs       | 2 +-
 tests/ext4/006    | 2 +-
 tests/generic/128 | 2 +-
 tests/generic/452 | 2 +-
 tests/xfs/293     | 2 +-
 tests/xfs/505     | 2 +-
 tests/xfs/514     | 2 +-
 tests/xfs/515     | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)
common/rc +1 -1
index a7f9ed86..db400c4d 100644
@@ -4,7 +4,7 @@
 
 . common/config
 
-BC=$(which bc 2> /dev/null) || BC=
+BC="$(type -P bc)" || BC=
 
 _require_math()
 {
src/fill2fs +1 -1
index 1c3383a8..d5e5436b 100755
@@ -111,7 +111,7 @@ sub normal {
 #
 
 chomp($cwd = `pwd`);
-chomp($_ = `which fill2 2>&1 | head -1`);
+chomp($_ = `type -P fill2 | head -1`);
 if (-x $_) {
   # look in the path
   $fill2 = fill2;
tests/ext4/006 +1 -1
index 17e77f86..48ed6bee 100755
@@ -24,7 +24,7 @@ _cleanup()
 . ./common/populate
 . ./common/fuzzy
 
-if [ ! -x "$(which e2fuzz)" ]; then
+if [ ! -x "$(type -P e2fuzz)" ]; then
 	_notrun "Couldn't find e2fuzz"
 fi
 
tests/generic/128 +1 -1
index dfc67fd5..dc1d43f4 100755
@@ -23,7 +23,7 @@ _scratch_mkfs >/dev/null 2>&1
 _scratch_mount "-o nosuid"
 
 mkdir $SCRATCH_MNT/nosuid
-cp `which ls` $SCRATCH_MNT
+cp "$(type -P ls)" $SCRATCH_MNT
 chmod 700 $SCRATCH_MNT/nosuid
 chmod 4755 $SCRATCH_MNT/ls
 
tests/generic/452 +0 -0
index ee4dfe9e..7cbd2dfa 100755
@@ -26,7 +26,7 @@ _exclude_scratch_mount_option "noexec"
 _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
Quoted 5 lines

tests/generic/452 _exclude_scratch_mount_option "noexec" · line 29

Quoted 2 lines
tests/generic/452 +1 -1
-LS=$(which ls --skip-alias --skip-functions)
+LS="$(type -P ls) --skip-alias --skip-functions)"

I think the "--skip-alias" and "--skip-functions" options are belong to the "which" command, so this change might cause fail.

Yay for command line parsing - invalid options are silently ignored by which on debian, so this actual command does the same thing as 'which ls'....

Really, though, I think I'm just going to allow the path to find ls in most cases - the only reason for using which ls was for tests that use it as a file copy source. If 'ls' is not in the default execution path, lots of stuff will not work...

Quoted 2 lines

tests/generic/452 _exclude_scratch_mount_option "noexec" · line 31

Quoted 2 lines
tests/generic/452 +0 -0
 SCRATCH_LS=$SCRATCH_MNT/ls_on_scratch
 cp $LS $SCRATCH_LS

Oh, look, copying the ls binary is exactly what this test is doing, so this would result in a cp failure...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#3 lore raw
In reply to Zorro Lang
Quoted 92 lines · Zorro Lang
Quoted 91 lines · Dave Chinner

From: Dave Chinner <[email protected]>

This patch is brought to you by the Department That Hates Users.

The latest debian unstable release is now causing a bunch of new test failures because they have deprecated the which command.

Rather than make everyone jump through hoops chasing problems with 'which' while debian decides to how to package at least three variants of 'which' - each which will different semantics, behaviour and support - as alternatives users then have to opt into, let's just remove the remaining uses of the shell independent 'which' command and replace them with bash builtin 'type -P' operations.

---

 common/rc         | 2 +-
 src/fill2fs       | 2 +-
 tests/ext4/006    | 2 +-
 tests/generic/128 | 2 +-
 tests/generic/452 | 2 +-
 tests/xfs/293     | 2 +-
 tests/xfs/505     | 2 +-
 tests/xfs/514     | 2 +-
 tests/xfs/515     | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)
common/rc +1 -1
index a7f9ed86..db400c4d 100644
@@ -4,7 +4,7 @@
 
 . common/config
 
-BC=$(which bc 2> /dev/null) || BC=
+BC="$(type -P bc)" || BC=
 
 _require_math()
 {
src/fill2fs +1 -1
index 1c3383a8..d5e5436b 100755
@@ -111,7 +111,7 @@ sub normal {
 #
 
 chomp($cwd = `pwd`);
-chomp($_ = `which fill2 2>&1 | head -1`);
+chomp($_ = `type -P fill2 | head -1`);
 if (-x $_) {
   # look in the path
   $fill2 = fill2;
tests/ext4/006 +1 -1
index 17e77f86..48ed6bee 100755
@@ -24,7 +24,7 @@ _cleanup()
 . ./common/populate
 . ./common/fuzzy
 
-if [ ! -x "$(which e2fuzz)" ]; then
+if [ ! -x "$(type -P e2fuzz)" ]; then
 	_notrun "Couldn't find e2fuzz"
 fi
 
tests/generic/128 +1 -1
index dfc67fd5..dc1d43f4 100755
@@ -23,7 +23,7 @@ _scratch_mkfs >/dev/null 2>&1
 _scratch_mount "-o nosuid"
 
 mkdir $SCRATCH_MNT/nosuid
-cp `which ls` $SCRATCH_MNT
+cp "$(type -P ls)" $SCRATCH_MNT
 chmod 700 $SCRATCH_MNT/nosuid
 chmod 4755 $SCRATCH_MNT/ls
 
tests/generic/452 +0 -0
index ee4dfe9e..7cbd2dfa 100755
@@ -26,7 +26,7 @@ _exclude_scratch_mount_option "noexec"
 _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
Quoted 5 lines

tests/generic/452 _exclude_scratch_mount_option "noexec" · line 29

Quoted 2 lines
tests/generic/452 +1 -1
-LS=$(which ls --skip-alias --skip-functions)
+LS="$(type -P ls) --skip-alias --skip-functions)"

I think the "--skip-alias" and "--skip-functions" options are belong to the "which" command, so this change might cause fail.

As Zorro pointed out, this causes LS to be

"/usr/bin/ls --skip-alias --skip-functions)"

and leads to the "cp $LS $SCRATCH_LS" failure as

+cp: unrecognized option '--skip-alias'
+Try 'cp --help' for more information.
+/root/workspace/xfstests/tests/generic/452: line 34: /mnt/scratch/ls_on_scratch: No such file or directory

So I've changed it to

LS="$(type -P ls)"

Thanks,
Eryu

Quoted 63 lines

Thanks,
Zorro

Quoted 58 lines
tests/generic/452 +0 -0
 SCRATCH_LS=$SCRATCH_MNT/ls_on_scratch
 cp $LS $SCRATCH_LS
 
tests/xfs/293 +1 -1
index fbd26b63..20f8c486 100755
@@ -30,7 +30,7 @@ case "$MANPAGE" in
 *)		CAT=cat;;
 esac
 
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_IO_PROG -c help | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
tests/xfs/505 +1 -1
index 8a999ff4..71fb6e9d 100755
@@ -26,7 +26,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_SPACEMAN_PROG -c help $TEST_DIR | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
tests/xfs/514 +1 -1
index a9c67645..cf5588f2 100755
@@ -34,7 +34,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 file=$TEST_DIR/xx.$seq
 truncate -s 128m $file
tests/xfs/515 +1 -1
index 32216fe6..2d7bbb35 100755
@@ -34,7 +34,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_QUOTA_PROG -x -c help $file | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
Signature · 1 line
2.31.1
#4 lore raw
In reply to Dave Chinner
Quoted 1 line

Subject: [PATCH] fstests: which has been deprecated by Debian

fstests has been deprecated by Debian? daaaang. ;)

Quoted 71 lines · Dave Chinner

From: Dave Chinner <[email protected]>

This patch is brought to you by the Department That Hates Users.

The latest debian unstable release is now causing a bunch of new test failures because they have deprecated the which command.

Rather than make everyone jump through hoops chasing problems with 'which' while debian decides to how to package at least three variants of 'which' - each which will different semantics, behaviour and support - as alternatives users then have to opt into, let's just remove the remaining uses of the shell independent 'which' command and replace them with bash builtin 'type -P' operations.

---
 common/rc         | 2 +-
 src/fill2fs       | 2 +-
 tests/ext4/006    | 2 +-
 tests/generic/128 | 2 +-
 tests/generic/452 | 2 +-
 tests/xfs/293     | 2 +-
 tests/xfs/505     | 2 +-
 tests/xfs/514     | 2 +-
 tests/xfs/515     | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)
common/rc +1 -1
index a7f9ed86..db400c4d 100644
@@ -4,7 +4,7 @@
 
 . common/config
 
-BC=$(which bc 2> /dev/null) || BC=
+BC="$(type -P bc)" || BC=
 
 _require_math()
 {
src/fill2fs +1 -1
index 1c3383a8..d5e5436b 100755
@@ -111,7 +111,7 @@ sub normal {
 #
 
 chomp($cwd = `pwd`);
-chomp($_ = `which fill2 2>&1 | head -1`);
+chomp($_ = `type -P fill2 | head -1`);
 if (-x $_) {
   # look in the path
   $fill2 = fill2;
tests/ext4/006 +1 -1
index 17e77f86..48ed6bee 100755
@@ -24,7 +24,7 @@ _cleanup()
 . ./common/populate
 . ./common/fuzzy
 
-if [ ! -x "$(which e2fuzz)" ]; then
+if [ ! -x "$(type -P e2fuzz)" ]; then
 	_notrun "Couldn't find e2fuzz"
 fi
 
tests/generic/128 +0 -0
index dfc67fd5..dc1d43f4 100755

tests/generic/128 _scratch_mkfs >/dev/null 2>&1 · line 26

Quoted 5 lines
tests/generic/128 +1 -1
@@ -23,7 +23,7 @@ _scratch_mkfs >/dev/null 2>&1
 _scratch_mount "-o nosuid"
 
 mkdir $SCRATCH_MNT/nosuid
-cp `which ls` $SCRATCH_MNT
+cp "$(type -P ls)" $SCRATCH_MNT

Given that FHS 3.0 section 3.4.2 requires ls to be in /bin, can we hardcode this into these tests?

Or, if we don't want to require FHS compliant distros, maybe we should just make $LS_PROG a general variable set up in common/rc?

Quoted 21 lines
tests/generic/128 +0 -0
 chmod 700 $SCRATCH_MNT/nosuid
 chmod 4755 $SCRATCH_MNT/ls
 
tests/generic/452 +1 -1
index ee4dfe9e..7cbd2dfa 100755
@@ -26,7 +26,7 @@ _exclude_scratch_mount_option "noexec"
 _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
-LS=$(which ls --skip-alias --skip-functions)
+LS="$(type -P ls) --skip-alias --skip-functions)"
 SCRATCH_LS=$SCRATCH_MNT/ls_on_scratch
 cp $LS $SCRATCH_LS
 
tests/xfs/293 +0 -0
index fbd26b63..20f8c486 100755

tests/xfs/293 case "$MANPAGE" in · line 33

Quoted 5 lines
tests/xfs/293 +1 -1
@@ -30,7 +30,7 @@ case "$MANPAGE" in
 *)		CAT=cat;;
 esac
 
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT

Same thing with cat.

--D

Quoted 45 lines
tests/xfs/293 +0 -0
 for COMMAND in `$XFS_IO_PROG -c help | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
tests/xfs/505 +1 -1
index 8a999ff4..71fb6e9d 100755
@@ -26,7 +26,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_SPACEMAN_PROG -c help $TEST_DIR | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
tests/xfs/514 +1 -1
index a9c67645..cf5588f2 100755
@@ -34,7 +34,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 file=$TEST_DIR/xx.$seq
 truncate -s 128m $file
tests/xfs/515 +1 -1
index 32216fe6..2d7bbb35 100755
@@ -34,7 +34,7 @@ case "$MANPAGE" in
 *.xz)		CAT=xzcat;;
 *)		CAT=cat;;
 esac
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT
 
 for COMMAND in `$XFS_QUOTA_PROG -x -c help $file | awk '{print $1}' | grep -v "^Use"`; do
   $CAT "$MANPAGE" | egrep -q "^\.B.*$COMMAND" || \
Signature · 1 line
2.31.1
#5 lore raw
Quoted 78 lines · Darrick J. Wong
Quoted 1 line

Subject: [PATCH] fstests: which has been deprecated by Debian

fstests has been deprecated by Debian? daaaang. ;)

Quoted 73 lines · Dave Chinner

From: Dave Chinner <[email protected]>

This patch is brought to you by the Department That Hates Users.

The latest debian unstable release is now causing a bunch of new test failures because they have deprecated the which command.

Rather than make everyone jump through hoops chasing problems with 'which' while debian decides to how to package at least three variants of 'which' - each which will different semantics, behaviour and support - as alternatives users then have to opt into, let's just remove the remaining uses of the shell independent 'which' command and replace them with bash builtin 'type -P' operations.

---
 common/rc         | 2 +-
 src/fill2fs       | 2 +-
 tests/ext4/006    | 2 +-
 tests/generic/128 | 2 +-
 tests/generic/452 | 2 +-
 tests/xfs/293     | 2 +-
 tests/xfs/505     | 2 +-
 tests/xfs/514     | 2 +-
 tests/xfs/515     | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)
common/rc +1 -1
index a7f9ed86..db400c4d 100644
@@ -4,7 +4,7 @@
 
 . common/config
 
-BC=$(which bc 2> /dev/null) || BC=
+BC="$(type -P bc)" || BC=
 
 _require_math()
 {
src/fill2fs +1 -1
index 1c3383a8..d5e5436b 100755
@@ -111,7 +111,7 @@ sub normal {
 #
 
 chomp($cwd = `pwd`);
-chomp($_ = `which fill2 2>&1 | head -1`);
+chomp($_ = `type -P fill2 | head -1`);
 if (-x $_) {
   # look in the path
   $fill2 = fill2;
tests/ext4/006 +1 -1
index 17e77f86..48ed6bee 100755
@@ -24,7 +24,7 @@ _cleanup()
 . ./common/populate
 . ./common/fuzzy
 
-if [ ! -x "$(which e2fuzz)" ]; then
+if [ ! -x "$(type -P e2fuzz)" ]; then
 	_notrun "Couldn't find e2fuzz"
 fi
 
tests/generic/128 +0 -0
index dfc67fd5..dc1d43f4 100755
@@ -23,7 +23,7 @@ _scratch_mkfs >/dev/null 2>&1
 _scratch_mount "-o nosuid"
 
Quoted 6 lines

tests/generic/128 _scratch_mkfs >/dev/null 2>&1 · line 26

Quoted 3 lines
tests/generic/128 +1 -1
 mkdir $SCRATCH_MNT/nosuid
-cp `which ls` $SCRATCH_MNT
+cp "$(type -P ls)" $SCRATCH_MNT

Given that FHS 3.0 section 3.4.2 requires ls to be in /bin, can we hardcode this into these tests?

For the binary copying, I'll just leave it like this. For all others, I'll just leave the path to find the ls binary.

Quoted 8 lines
Quoted 8 lines
tests/xfs/293 +0 -0
index fbd26b63..20f8c486 100755
@@ -30,7 +30,7 @@ case "$MANPAGE" in
 *)		CAT=cat;;
 esac
 
Quoted 4 lines

tests/xfs/293 case "$MANPAGE" in · line 33

Quoted 2 lines
tests/xfs/293 +1 -1
-_require_command `which $CAT` $CAT
+_require_command "$(type -P $CAT)" $CAT

Same thing with cat.

Except $CAT might be something other than "cat" here. i.e.:

case "$MANPAGE" in

*.gz|*.z\|*.Z)  CAT=zcat;;
*.bz2)          CAT=bzcat;;
*.xz)           CAT=xzcat;;
*)              CAT=cat;;

esac

_require_command "$(type -P $CAT)" $CAT

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]