mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 19:52:20 +00:00
This commit replaces the old hash alias with a proper builtin. I based this builtin off of the code alias uses for handling `alias -t --`, but with the hack for `--` removed as it has no use in the new builtin. `alias -t --` will no longer work, that hack is now gone. While I was testing this builtin, I found a bug with hash tables in non-forking subshells. If the hash table of a non-forking subshell is changed, the parent shell's hash table is also changed. As an example, running `(hash -r)` was resetting the parent shell's hash table. The workaround is to force the subshell to fork if the hash table will be changed. src/cmd/ksh93/bltins/typeset.c: - Move the code for hash out of the alias builtin into a dedicated hash builtin. `alias -t --` is no longer supported. src/cmd/ksh93/data/aliases.c: - Remove the old alias for hash from the table of predefined aliases. src/cmd/ksh93/data/builtins.c: - Fix the broken entry for the hash builtin and add a man page for the new builtin. src/cmd/ksh93/sh.1: - Replace the entry for the hash alias with a more detailed entry for the hash builtin. src/cmd/ksh93/sh/name.c: - Force non-forking subshells to fork if the PATH is being reset to workaround a bug with the hash tree. src/cmd/ksh93/tests/alias.sh: - Add a regression test for resetting a hash table, then adding a utility to the refreshed hash table. src/cmd/ksh93/tests/subshell.sh: - Add regression tests for changing the hash table in subshells. (cherry picked from commit d8428a833afe9270b61745ba3d6df355fe1d5499)
106 lines
4.8 KiB
Text
106 lines
4.8 KiB
Text
TODO for AT&T ksh93, 93u+m bugfix branch
|
||
|
||
______
|
||
Fix regression test failures:
|
||
|
||
- On FreeBSD, there is a test failure in [[ -N file ]] in bracket.sh.
|
||
- On OpenBSD, there are 15 locale-related test failures in variables.sh.
|
||
|
||
______
|
||
Fix build system:
|
||
|
||
- ksh does not currently build on NetBSD, AIX, HP-UX, Solaris, or QNX.
|
||
- Reimport the removed nmake. It is necessary for changes in Makefiles
|
||
to take effect. The machine-generated Mamfiles are now used as a fallback,
|
||
but they are not meant to be edited by hand.
|
||
- Reimport the removed pty command (for scripting interactive sessions). This
|
||
is necessary for the pty.sh regression tests to work, which test ksh as an
|
||
interactive shell. We want to avoid breaking the interactive shell, too.
|
||
|
||
______
|
||
Fix or remove broken or misguided default aliases:
|
||
|
||
- Make a proper builtin out of the redirect='command exec' alias. It should
|
||
really only parse redirections. Currently, if an unwitting user notices this
|
||
alias and tries out something like 'redirect ls >file', it does 'exec ls
|
||
>file', so 'ls' replaces their shell and they get logged out. That is so
|
||
misdesigned I'm calling it a bug.
|
||
Alternatively, maybe just get rid? Who uses this anyway? 'redirect >&2'
|
||
takes four more keystrokes to type than 'exec >&2'.
|
||
|
||
- Make proper builtins out of the following scripting-related aliases, so
|
||
that 'unalias -a' does not eliminate them. If done correctly, this causes
|
||
no other change in behaviour. It would be good practice to 'unalias -a' in
|
||
a script to start with a clean slate, except ksh has always made that
|
||
impossible without losing these. Default aliases should be to facilitate
|
||
interactive use.
|
||
- autoload='typeset -fu'
|
||
- compound='typeset -C'
|
||
- float='typeset -lE'
|
||
- functions='typeset -f'
|
||
- integer='typeset -li'
|
||
- nameref='typeset -n'
|
||
- source='command .'
|
||
Keep these default aliases for the benefit of interactive shells:
|
||
+ history='hist -l'
|
||
+ r='hist -s'
|
||
+ stop='kill -s STOP'
|
||
+ suspend='kill -s STOP $$'
|
||
|
||
______
|
||
Fix currently known bugs affecting shell scripting. These are identified by
|
||
their modernish IDs. For exact details, see code/comments in:
|
||
https://github.com/modernish/modernish/tree/0.16/lib/modernish/cap/
|
||
|
||
- BUG_BRACQUOT: shell quoting within bracket patterns has no effect. This
|
||
bug means the '-' retains it special meaning of 'character range', and an
|
||
initial ! (and, on some shells, ^) retains the meaning of negation, even
|
||
in quoted strings within bracket patterns, including quoted variables.
|
||
|
||
- BUG_CMDEXPAN: if the 'command' command results from an expansion, it acts
|
||
like 'command -v', showing the path of the command instead of executing it.
|
||
For example:
|
||
v=command; "$v" ls
|
||
or
|
||
set -- command ls; "$@"
|
||
don't work.
|
||
See also: https://github.com/att/ast/issues/963
|
||
|
||
- BUG_CMDSPASGN: preceding a "special builtin"[*] with 'command' does not
|
||
stop preceding invocation-local variable assignments from becoming global.
|
||
[*] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14
|
||
|
||
- BUG_CMDSPEXIT: preceding a "special builtin"[*] (other than 'eval', 'exec',
|
||
'return' or 'exit') with 'command' does not always stop it from exiting
|
||
the shell if the builtin encounters error.
|
||
[*] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14
|
||
|
||
- BUG_CSUBSTDO: If standard output (file descriptor 1) is closed before
|
||
entering a $(command substitution), and any other file descriptors are
|
||
redirected within the command substitution, commands such as 'echo' will
|
||
not work within the command substitution, acting as if standard output is
|
||
still closed.
|
||
|
||
- BUG_IFSGLOBS: In glob pattern matching (as in case or parameter
|
||
substitution with # and %), if IFS starts with ? or * and the "$*"
|
||
parameter expansion inserts any IFS separator characters, those characters
|
||
are erroneously interpreted as wildcards when quoted "$*" is used as the
|
||
glob pattern.
|
||
|
||
- BUG_KUNSETIFS: ksh93: Can't unset IFS under very specific circumstances.
|
||
unset -v IFS is a known POSIX shell idiom to activate default field
|
||
splitting. With this bug, the unset builtin silently fails to unset IFS
|
||
(i.e. fails to activate field splitting) if we're executing an eval or a
|
||
trap and a number of specific conditions are met.
|
||
|
||
- BUG_LOOPRET2: If a 'return' command is given without a status argument
|
||
within the set of conditional commands in a 'while' or 'until' loop (i.e.,
|
||
between 'while'/'until' and 'do'), the exit status passed down from the
|
||
previous command is ignored and the function returns with status 0
|
||
instead.
|
||
|
||
- BUG_MULTIBIFS: We're on a UTF-8 locale and the shell supports UTF-8
|
||
characters in general (i.e. we don't have WRN_MULTIBYTE) – however, using
|
||
multi-byte characters as IFS field delimiters still doesn't work. For
|
||
example, "$*" joins positional parameters on the first byte of IFS instead
|
||
of the first character.
|