mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Backport -P and -t flags for 'type'/'whence' from ksh93v- (#392)
This commit backports the whence '-t' option from ksh93v-. The '-t' option is useful when one needs to identify the type of a command. The '-t' flag was added by ksh93v- for compatibility with Bash. It should be noted the ksh93v- patch had one bug, which this commit fixes. Path-bound builtins from /opt/ast/bin were classified as files if loaded from /opt/ast/bin in the PATH. Reproducer: $ PATH=/opt/ast/bin whence -t cat file src/cmd/ksh93/bltins/whence.c: - Simplify the bitmask values for the command and whence builtin flags. - Add the -t flag to the whence and type builtins. To prevent bugs, -t will always override -v if both of those flags were passed. src/cmd/ksh93/data/builtins.c, src/cmd/ksh93/sh.1: - Add documentation for the new -t option.
This commit is contained in:
parent
2027648f1a
commit
24174f0fb7
7 changed files with 181 additions and 32 deletions
|
|
@ -2051,7 +2051,7 @@ _JOB_
|
|||
;
|
||||
|
||||
const char sh_optwhence[] =
|
||||
"[-1c?\n@(#)$Id: whence (ksh 93u+m) 2020-09-25 $\n]"
|
||||
"[-1c?\n@(#)$Id: whence (ksh 93u+m) 2021-12-27 $\n]"
|
||||
"[--catalog?" SH_DICT "]"
|
||||
"[+NAME?whence, type - locate a command and describe its type]"
|
||||
"[+DESCRIPTION?Without \b-v\b, \bwhence\b writes on standard output an "
|
||||
|
|
@ -2064,8 +2064,11 @@ const char sh_optwhence[] =
|
|||
"[+?The \btype\b command is equivalent to \bwhence -v\b.]"
|
||||
"[a?Like \b-v\b but displays all uses for each \aname\a rather than the first.]"
|
||||
"[f?Do not check for functions.]"
|
||||
"[p?Do not check to see if \aname\a is a reserved word, a built-in, "
|
||||
"[p|P?Do not check to see if \aname\a is a reserved word, a built-in, "
|
||||
"an alias, or a function. This turns off the \b-v\b option.]"
|
||||
"[t?Output only a single-word type indicator for each \aname\a found: "
|
||||
"\bkeyword\b, \balias\b, \bbuiltin\b, \bfunction\b or \bfile\b. "
|
||||
"This turns off the \b-v\b option.]"
|
||||
"[q?Quiet mode. Returns 0 if all arguments are built-ins, functions, or are "
|
||||
"programs found on the path.]"
|
||||
"[v?For each name you specify, the shell displays a line that indicates "
|
||||
|
|
|
|||
|
|
@ -103,11 +103,7 @@ const char sh_opttest[] =
|
|||
"[+-e \afile\a?\afile\a exists and is not a broken symlink.]"
|
||||
"[+-f \afile\a?\afile\a is a regular file.]"
|
||||
"[+-g \afile\a?\afile\a has its set-group-id bit set.]"
|
||||
"[+-h \afile\a?Same as \b-L\b.]"
|
||||
"[+-k \afile\a *?\afile\a has its sticky bit on.]"
|
||||
#if SHOPT_TEST_L
|
||||
"[+-l \afile\a *?Same as \b-L\b.]"
|
||||
#endif
|
||||
"[+-n \astring\a?Length of \astring\a is non-zero.]"
|
||||
"[+-o \aoption\a *?Shell option \aoption\a is enabled.]"
|
||||
"[+-p \afile\a?\afile\a is a FIFO.]"
|
||||
|
|
@ -122,7 +118,11 @@ const char sh_opttest[] =
|
|||
"[+-z \astring\a?\astring\a is a zero-length string.]"
|
||||
"[+-G \afile\a *?Group of \afile\a is the effective "
|
||||
"group ID of the current process.]"
|
||||
"[+-L \afile\a?\afile\a is a symbolic link.]"
|
||||
#if SHOPT_TEST_L
|
||||
"[+-L|l|h \afile\a?\afile\a is a symbolic link.]"
|
||||
#else
|
||||
"[+-L|h \afile\a?\afile\a is a symbolic link.]"
|
||||
#endif
|
||||
"[+-N \afile\a *?\afile\a has been modified since it was last read.]"
|
||||
"[+-O \afile\a *?\afile\a exists and owner is the effective "
|
||||
"user ID of the current process.]"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue