1
0
Fork 0
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:
Johnothan King 2021-12-26 22:37:01 -08:00 committed by Martijn Dekker
parent 2027648f1a
commit 24174f0fb7
7 changed files with 181 additions and 32 deletions

View file

@ -35,6 +35,18 @@ To get involved in development, read the brief policy information in
README.md and then jump right in with a pull request or email a patch.
See the TODO file in the top-level directory for a to-do list.
### MAIN CHANGES between 1.0.0-beta.2 and 1.0.0-(unreleased) ###
New features in built-in commands:
- Two bash-like flags for 'whence' were backported from ksh 93v-:
- 'whence -P/type -P' is an alias to the existing -p flag.
- 'whence -t/type -t' will print only the type of a command in a simple
format that is designed to be easy to use for scripts. Example:
$ type -t typeset; whence -t sh
builtin
file
### MAIN CHANGES between 1.0.0-beta.1 and 1.0.0-beta.2 ###
New features in built-in commands: