Re: 'type' builtin in posix-only shell
Stephane CHAZELAS <this.address@is.invalid> wrote, on Thu, 09 Nov 2006:
>> You have it backwards: "type" is UNIX, "command -v" is POSIX.
> But "command -v" is required by XSI (Unix if I understand
> correctly) and optionnal in POSIX.
>
> | -v
> | (On systems supporting the User Portability
> | Utilities option.) Write a string to standard
> | output that indicates the pathname or command that
> | will be used by the shell, in the current shell
> | execution environment (see Shell Execution
> | Environment ), to invoke command_name, but do not
> | invoke command_name.
This says -v is part of the User Portability Utilities (UP) option.
UP is a POSIX option. Thus "command -v is POSIX" (despite being
optional).
By contrast, "type" is marked XSI in the standard, thus "type is UNIX".
> | XSI Shell and Utilities Conformance
> |
> | * The system shall support all the utilities defined in the
> | Shell and Utilities volume of IEEE Std 1003.1-2001 as
> | part of the XSI extension denoted by
> | the XSI marking in the SYNOPSIS section, and any
> | extensions marked with the XSI extension marking (see
> | Codes) within the text.
> |
> | * The system shall support the User Portability Utilities
> | option.
This says that the POSIX UP option is mandated for XSI conforming
(i.e. UNIX) systems.
Several other POSIX options are also mandated for XSI conformance,
there is nothing unique about UP here.
> If it's optional, that means a script can't use it.
It means that a script which uses it assumes that the system
supports the UP option. So does a script that uses any of
these utilities:
csplit, df, du, ex, expand, file, more, nice, patch, ps,
renice, split, strings, time, tput, unexpand, uudecode,
uuencode, who
> And posh implements neither type nor command -v
Could be an oversight. Does posh implement other UP features
of the shell, such as alias, fc, fg/bg, or interactive command
line editing?
--
Geoff Clare <netnews@gclare.org.uk>
|