Discussion:
[ast-users] Default path not searched when using "command -p"
Andreas Kusalananda Kähäri
2017-03-01 08:53:41 UTC
Permalink
Hi,

It appears as if the "command -p" command in Version AJM 93u+ 2012-08-01
does not find standard utilities under some circumstances.

Consider the script "testing":

command -p mkdir t

"command -p" is supposed to look up and execute the given utility in a
"default path" (which I believe is /bin:/usr/bin: in ksh93).

Running this:

$ ksh93 -x testing
+ command -p mkdir t
testing[1]: mkdir: not found [No such file or directory]

The same command works when executed on the command line, and the mkdir
utility is found in /bin:

$ command -v mkdir
/bin/mkdir

If the "command -p" command is preceded in by any command that provokes
a PATH search, the command succeeds.

The "bulitin" command of ksh93 lists mkdir and some other standard and
nonstandard utilities under the non-existent path /opt/ast/bin. None of
these utilities are found by "command -p" unless a successful PATH
search has first occurred.

This behaviour has been observed on macOS and Solaris (system
default ksh93), as well as on OpenBSD and Ubuntu (with ksh93 from
ports/packages).

I'm uncertain whether I'm missing something in my reading of the POSIX
description of "command -p" or the ksh93 manual's description of the same
command, or if it's a bug. I'm further mystified by the /opt/ast/bin
path used for some built in utilities.

With kind regards,
Andreas

Loading...