Skip to content

Commit

Permalink
37591: 'alias -L': skip with a warning aliases with '=' in their LHS
Browse files Browse the repository at this point in the history
  • Loading branch information
danielshahaf committed Jan 13, 2016
1 parent 152875b commit a8a00be
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
@@ -1,5 +1,8 @@
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
line-device names; fail gracefully on OSes matching no known
line-device name pattern.
Expand Down
9 changes: 9 additions & 0 deletions Src/hashtable.c
Expand Up @@ -1276,6 +1276,15 @@ printaliasnode(HashNode hn, int printflags)
}

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 ");
if (a->node.flags & ALIAS_SUFFIX)
printf("-s ");
Expand Down
8 changes: 8 additions & 0 deletions Test/A02alias.ztst
Expand Up @@ -96,3 +96,11 @@
0:unalias -as
>foo is a suffix alias for print
>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.

0 comments on commit a8a00be

Please sign in to comment.