Op 05-03-16 om 18:23 schreef Thorsten Glaser:
> Martijn Dekker dixit:
>
>> 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.
>
>> Finally, an external command was still missing from the test and it
>> seems like a good idea to add one.
>
> I don’t think so, what do you make of true=ENOENT
The existence of 'true' as an external command somewhere in the default
system $PATH (whatever that is) is mandated by POSIX, as it is for all
regular builtins, and this is also the historical practice.
Consequently, 'whence -p true' should always work given a default path,
unless the system is so broken that the user has bigger problems to
worry about than mksh bugs.
> and /system/bin/ls
> or *shudder* ls.exe? (These are the challenges mksh faces…)
The attached version matches .*/true.* and .*/ls.* so any possible path
and any possible extensions are covered.
- M.
Index: check.t
===================================================================
RCS file: /cvs/src/bin/mksh/check.t,v
retrieving revision 1.728
diff -u -r1.728 check.t
--- check.t 5 Mar 2016 15:40:00 -0000 1.728
+++ check.t 10 Mar 2016 19:37:04 -0000
@@ -12202,17 +12202,17 @@
words, and command -p[vV] should find aliases, reserved words, and
builtins over external commands.
stdin:
- PATH=/bin:/usr/bin
+ 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'; do
+ 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:
- if
+expected-stdout-pattern:
+ /^if
if
if is a reserved word
if is a reserved word
@@ -12232,25 +12232,28 @@
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.
-category: os:mirbsd
stdin:
- PATH=/bin:/usr/bin
+ 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'; do
+ for word in 'if' 'foo' 'bar' 'set' 'true' 'ls'; do
whence "$word"
whence -p "$word"
whence -v "$word"
whence -pv "$word"
done
-expected-stdout:
- if
+expected-stdout-pattern:
+ /^if
if is a reserved word
if not found
'bar baz'
@@ -12263,9 +12266,13 @@
set is a special shell builtin
set not found
true
- /bin/true
+ .*\/true.*
true is a shell builtin
- true is a tracked alias for /bin/true
+ 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: