forked from pfsense/FreeBSD-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sh: Write absolute path in command -vV and type
POSIX is pretty clear that command -v, command -V and type shall write absolute pathnames. Therefore, we need to prepend the current directory's name to relative pathnames. This can happen either when PATH contains a relative pathname or when the operand contains a slash but is not an absolute pathname.
- Loading branch information
Showing
5 changed files
with
64 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# $FreeBSD$ | ||
|
||
failures=0 | ||
|
||
check() { | ||
if [ "$1" != "$2" ] && { [ "$#" -lt 3 ] || [ "$1" != "$3" ]; } then | ||
echo "Mismatch found" | ||
echo "Expected: $2" | ||
if [ "$#" -ge 3 ]; then | ||
echo "Alternative expected: $3" | ||
fi | ||
echo "Actual: $1" | ||
: $((failures += 1)) | ||
fi | ||
} | ||
|
||
check "$(cd /bin && PATH=. command -v ls)" /bin/ls /bin/./ls | ||
check "$(cd /bin && PATH=:/var/empty/nosuch command -v ls)" /bin/ls /bin/./ls | ||
check "$(cd / && PATH=bin command -v ls)" /bin/ls | ||
check "$(cd / && command -v bin/ls)" /bin/ls | ||
check "$(cd /bin && command -v ./ls)" /bin/ls /bin/./ls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# $FreeBSD$ | ||
|
||
r=`cd /bin && PATH=. command -V ls` | ||
case $r in | ||
*/bin/ls*|*/bin/./ls*) ;; | ||
*) | ||
echo "Unexpected result: $r" | ||
exit 1 | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# $FreeBSD$ | ||
|
||
r=`cd /bin && PATH=. type ls` | ||
case $r in | ||
*/bin/ls*|*/bin/./ls*) ;; | ||
*) | ||
echo "Unexpected result: $r" | ||
exit 1 | ||
esac |