Thorsten Glaser schreef op 05-03-16 om 16:27:
> I think I’ll mark your second test as MirBSD-only after moving true
> from /usr/bin to /bin where we have it, this way the logic gets full
> coverage but we only run the portable test elsewhere.
Ah yes, I didn't think of the hardcoded /usr/bin/true path, oops.
That's nothing that can't be fixed with a simple regex.
I've also added a call to 'getconf PATH' to ensure a system default path
for these tests, with a fallback for ancient systems without 'getconf'.
Finally, an external command was still missing from the test and it
seems like a good idea to add one.
- M.
Index: check.t
===================================================================
RCS file: /cvs/src/bin/mksh/check.t,v
retrieving revision 1.726
diff -u -r1.726 check.t
--- check.t 1 Mar 2016 18:30:25 -0000 1.726
+++ check.t 5 Mar 2016 16:13:20 -0000
@@ -12196,13 +12196,83 @@
after 0='swc' 1='äº' 2=''
= done
---
-name: command-path
+name: command-pvV-posix-priorities
description:
- Check 'command -p' is not 'whence -p'
-stdin:
- command -pv if
-expected-stdout:
+ For POSIX compatibility, command -v should find aliases and reserved
+ words, and command -p[vV] should find aliases, reserved words, and
+ builtins over external commands.
+stdin:
+ PATH=$(command -p getconf PATH 2>/dev/null) || PATH=/bin:/usr/bin
+ alias foo="bar baz"
+ bar() { :; }
+ for word in 'if' 'foo' 'bar' 'set' 'true' 'ls'; do
+ command -v "$word"
+ command -pv "$word"
+ command -V "$word"
+ command -pV "$word"
+ done
+expected-stdout-pattern:
+ /^if
if
+ if is a reserved word
+ if is a reserved word
+ alias foo='bar baz'
+ alias foo='bar baz'
+ foo is an alias for 'bar baz'
+ foo is an alias for 'bar baz'
+ bar
+ bar
+ bar is a function
+ bar is a function
+ set
+ set
+ set is a special shell builtin
+ set is a special shell builtin
+ true
+ true
+ true is a shell builtin
+ true is a shell builtin
+ .*\/ls
+ .*\/ls
+ ls is a tracked alias for .*\/ls
+ ls is .*\/ls$/
+---
+name: whence-preserve-tradition
+description:
+ This regression test is to ensure that the POSIX compatibility
+ changes for 'command' (see previous test) do not affect traditional
+ 'whence' behaviour.
+stdin:
+ PATH=$(command -p getconf PATH 2>/dev/null) || PATH=/bin:/usr/bin
+ alias foo="bar baz"
+ bar() { :; }
+ for word in 'if' 'foo' 'bar' 'set' 'true' 'ls'; do
+ whence "$word"
+ whence -p "$word"
+ whence -v "$word"
+ whence -pv "$word"
+ done
+expected-stdout-pattern:
+ /^if
+ if is a reserved word
+ if not found
+ 'bar baz'
+ foo is an alias for 'bar baz'
+ foo not found
+ bar
+ bar is a function
+ bar not found
+ set
+ set is a special shell builtin
+ set not found
+ true
+ .*\/true
+ true is a shell builtin
+ true is a tracked alias for .*\/true
+ .*\/ls
+ .*\/ls
+ ls is a tracked alias for .*\/ls
+ ls is a tracked alias for .*\/ls$/
---
name: duffs-device
description: