mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
posix: re-allow preset aliases on interactive (re: ddaa145b
)
The POSIX standard in fact contains a sentence that specifically allows preset aliases: "Implementations also may provide predefined valid aliases that are in effect when the shell is invoked." https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_03_01 I had missed that back then. It's still a terrible idea for scripts (particularly the way 93u+ implemented them), but for interactive POSIX shells it makes a lot more sense and does not violate POSIX. src/cmd/ksh93/sh/main.c: sh_main(): - Preset aliases for interactive shell regardless of SH_POSIX.
This commit is contained in:
parent
b14e79e9d0
commit
4f9456d69f
3 changed files with 9 additions and 14 deletions
3
NEWS
3
NEWS
|
@ -11,6 +11,9 @@ Any uppercase BUG_* names are modernish shell bug IDs.
|
|||
<##pattern redirection operators will not work and the -n option to the
|
||||
read built-in will not return early when reading from a slow device.)
|
||||
|
||||
- An interactive shell initialized in POSIX mode now once again has the
|
||||
preset aliases defined. This amends a change made on 2020-09-11.
|
||||
|
||||
2022-06-08:
|
||||
|
||||
- If -B/--braceexpand is turned on in --posix mode, it now only allows brace
|
||||
|
|
|
@ -811,11 +811,7 @@ definition command has to be executed before
|
|||
the command which references the alias is read.
|
||||
.PP
|
||||
The following aliases are automatically preset
|
||||
when the shell is invoked as an interactive shell,
|
||||
unless invoked in POSIX compliance mode
|
||||
(see
|
||||
.I Invocation\^
|
||||
below).
|
||||
when the shell is invoked as an interactive shell.
|
||||
Preset aliases can be unset or redefined.
|
||||
.RS 20
|
||||
.PD 0
|
||||
|
@ -7700,9 +7696,8 @@ is automatically turned on upon invocation if the shell is invoked as \fBsh\fR
|
|||
or \fBrsh\fR, or if \fB\-o posix\fR or \fB\-\-posix\fR is specified on the
|
||||
shell invocation command line, or when executing scripts without a \fB#!\fR path
|
||||
with this option active in the invoking shell. In that case, the invoked shell
|
||||
will not set the preset aliases even if interactive, and will not import type
|
||||
attributes for variables (such as integer or left/right justify)
|
||||
from the environment.
|
||||
will not import type attributes for variables (such as integer or left/right
|
||||
justify) from the environment.
|
||||
.RS 8
|
||||
.PP
|
||||
In addition, while on, the \fBposix\fR option
|
||||
|
|
|
@ -166,12 +166,9 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
|
|||
{
|
||||
sh_onoption(SH_BGNICE);
|
||||
sh_onoption(SH_RC);
|
||||
if(!sh_isoption(SH_POSIX))
|
||||
{
|
||||
/* preset aliases for interactive non-POSIX ksh */
|
||||
dtclose(sh.alias_tree);
|
||||
sh.alias_tree = sh_inittree(shtab_aliases);
|
||||
}
|
||||
/* preset aliases for interactive ksh/sh */
|
||||
dtclose(sh.alias_tree);
|
||||
sh.alias_tree = sh_inittree(shtab_aliases);
|
||||
}
|
||||
#if SHOPT_REMOTE
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue