1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-05-19 23:21:25 +02:00

26675: add POSIX_ALIASES option

This commit is contained in:
Peter Stephenson 2009-03-03 17:26:03 +00:00
parent 919f7b12ad
commit 8e25f4449f
6 changed files with 58 additions and 3 deletions

View file

@ -1,5 +1,8 @@
2009-03-03 Peter Stephenson <pws@csr.com>
* Doc/Zsh/options.yo, Src/lex.c, Src/options.c, Src/zsh.h,
Test/A02alias.ztst: add POSIX_ALIASES option.
* 26671: Completion/Zsh/Command/_zattr, Doc/Zsh/.distfiles,
Src/Modules/attr.c: various minor tidy-ups (tidies up?) for
26670.
@ -11308,5 +11311,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4593 $
* $Revision: 1.4594 $
*****************************************************

View file

@ -1708,6 +1708,43 @@ is not and will replace the first element of the array.
This option is for compatibility with older versions of the shell and
is not recommended in new code.
)
pindex(POSIX_ALIASES)
pindex(NO_POSIX_ALIASES)
pindex(POSIXALIASES)
pindex(NOPOSIXALIASES)
item(tt(POSIX_ALIASES) <K> <S>)(
When this option is set, reserved words are not candidates for
alias expansion: it is still possible to declare any of them as an alias,
but the alias will never be expanded. Reserved words are
tt(!),
tt([[),
tt({),
tt(}),
tt(case),
tt(coproc),
tt(do),
tt(done),
tt(elif),
tt(else),
tt(end),
tt(esac),
tt(fi),
tt(for),
tt(foreach),
tt(function),
tt(if),
tt(nocorrect),
tt(repeat),
tt(select),
tt(then),
tt(time),
tt(until),
tt(while).
Alias expansion takes place while text is being read; hence when this
option is set it does not take effect until the end of any function or
other piece of shell code evaluated as one unit.
)
pindex(POSIX_BUILTINS)
pindex(NO_POSIX_BUILTINS)
pindex(POSIXBUILTINS)

View file

@ -1748,9 +1748,11 @@ exalias(void)
if (tok == STRING) {
/* Check for an alias */
if (!noaliases && isset(ALIASESOPT)) {
if (!noaliases && isset(ALIASESOPT) &&
(!isset(POSIXALIASES) ||
!reswdtab->getnode(reswdtab, zshlextext))) {
char *suf;
an = (Alias) aliastab->getnode(aliastab, zshlextext);
if (an && !an->inuse &&
((an->node.flags & ALIAS_GLOBAL) || incmdpos || inalmore)) {

View file

@ -198,6 +198,7 @@ static struct optname optns[] = {
{{NULL, "octalzeroes", OPT_EMULATE|OPT_SH}, OCTALZEROES},
{{NULL, "overstrike", 0}, OVERSTRIKE},
{{NULL, "pathdirs", OPT_EMULATE}, PATHDIRS},
{{NULL, "posixaliases", OPT_EMULATE|OPT_BOURNE}, POSIXALIASES},
{{NULL, "posixbuiltins", OPT_EMULATE|OPT_BOURNE}, POSIXBUILTINS},
{{NULL, "posixidentifiers", OPT_EMULATE|OPT_BOURNE}, POSIXIDENTIFIERS},
{{NULL, "printeightbit", 0}, PRINTEIGHTBIT},

View file

@ -1933,6 +1933,7 @@ enum {
OCTALZEROES,
OVERSTRIKE,
PATHDIRS,
POSIXALIASES,
POSIXBUILTINS,
POSIXIDENTIFIERS,
PRINTEIGHTBIT,

View file

@ -25,3 +25,14 @@
\bar \bar
0:Aliasing with a backslash
>bar
(alias '!=echo This command has the argument'
eval 'print Without
! true'
setopt posixaliases
eval 'print With
! true')
1:POSIX_ALIASES option
>Without
>This command has the argument true
>With