I have an issue with using
command -p mkdir in a
ksh93 shell script.
command -p bit is supposed to, according to POSIX,
Perform the command search using a default value for
PATHthat is guaranteed to find all of the standard utilities.
ksh93 manual has a similar wording:
-poption causes a default path to be searched rather than the one defined by the value of
PATH. Functions will not be searched for when finding name. In addition, if name refers to a special built-in, none of the special properties associated with the leading daggers will be honored. (For example, the predefined alias
redirect='command exec'prevents a script from terminating when an invalid redirection is given.)
I've boiled my script down to the following:
#!/usr/local/bin/ksh93 -x echo "$PATH" command -p mkdir t
$ ./test.sh + echo /usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin /usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin + command -p mkdir t ./test.sh: mkdir: not found [No such file or directory]
The default value of
ksh93 (according to its manual) is
mkdir is found in
$ command -v mkdir /bin/mkdir
If I issue the
getconf PATH command in the script (to get the value of the default system-defined
$PATH), before calling
mkdir, the call to
This is seen in
ksh93, "Version AJM 93u+ 2012-08-01", on at least Ubuntu, OpenBSD, macOS and Solaris, and also affect at least
cat when invoked the same way.
The question: Did I miss something obvious here?
builtin command in
ksh93 lists a number of utilities under the (non-existent) path
/opt/ast/bin. Does this have something to do with this?
$ builtin : . [ /opt/ast/bin/basename /opt/ast/bin/cat /opt/ast/bin/chmod /opt/ast/bin/cmp /opt/ast/bin/cut /opt/ast/bin/dirname /opt/ast/bin/getconf /opt/ast/bin/head /opt/ast/bin/logname /opt/ast/bin/mkdir /opt/ast/bin/sync /opt/ast/bin/uname /opt/ast/bin/wc alarm alias
UPDATE: I have submitted this query to the
ast-users mailing list as well.