1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-08 06:12:10 +02:00

37591: 'alias -L': skip with a warning aliases with '=' in their LHS

This commit is contained in:
Daniel Shahaf 2016-01-13 00:57:55 +00:00
parent 152875ba03
commit a8a00be442
3 changed files with 20 additions and 0 deletions

View file

@ -1,5 +1,8 @@
2016-01-13 Daniel Shahaf <d.s@daniel.shahaf.name> 2016-01-13 Daniel Shahaf <d.s@daniel.shahaf.name>
* 37591: Src/hashtable.c, Test/A02alias.ztst: 37591: 'alias -L':
skip with a warning aliases with '=' in their LHS
* 37550: Completion/BSD/Command/_cu: _cu: Support Linux * 37550: Completion/BSD/Command/_cu: _cu: Support Linux
line-device names; fail gracefully on OSes matching no known line-device names; fail gracefully on OSes matching no known
line-device name pattern. line-device name pattern.

View file

@ -1276,6 +1276,15 @@ printaliasnode(HashNode hn, int printflags)
} }
if (printflags & PRINT_LIST) { if (printflags & PRINT_LIST) {
/* Fast fail on unrepresentable values. */
if (strchr(a->node.nam, '=')) {
zwarn("invalid alias '%s' encountered while printing aliases",
a->node.nam);
/* ### TODO: Return an error status to the C caller */
return;
}
/* Normal path. */
printf("alias "); printf("alias ");
if (a->node.flags & ALIAS_SUFFIX) if (a->node.flags & ALIAS_SUFFIX)
printf("-s "); printf("-s ");

View file

@ -96,3 +96,11 @@
0:unalias -as 0:unalias -as
>foo is a suffix alias for print >foo is a suffix alias for print
>foo: suffix alias >foo: suffix alias
aliases[x=y]=z
alias -L | grep x=y
echo $pipestatus[1]
0:printing invalid aliases warns
>0
?(eval):2: invalid alias 'x=y' encountered while printing aliases
# Currently, 'alias -L' returns 0 in this case. Perhaps it should return 1.