Original-Report: https://savannah.gnu.org/support/index.php?108708 Reporter: Pasha Bolokhov
Alias produces non-reusable output: dualbus@yaqui:~$ alias -- -x='echo x' dualbus@yaqui:~$ alias -p alias -x='echo x' alias ls='ls --color=auto' 'help alias' claims it's reusable: alias -p|grep reusable dualbus@yaqui:~$ help alias|grep reusable Without arguments, `alias' prints the list of aliases in the reusable -p Print all defined aliases in a reusable format The original report also contains the attached patch. -- Eduardo Bustamante | https://dualbus.me/
>From a0e0690489aaa68cd93bc0eff7706c87c33caec7 Mon Sep 17 00:00:00 2001 From: Pasha Bolokhov <pasha.bolok...@gmail.com> Date: Sat, 20 Dec 2014 16:45:05 -0800 Subject: [PATCH] Fix output for an alias starting with a dash When an alias name starts with '-' the 'alias' command now inserts a double-dash to make sure the name in not treated as an option: alias -- <name>=<value> --- builtins/alias.def | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/builtins/alias.def b/builtins/alias.def index d760ceb..892f165 100644 --- a/builtins/alias.def +++ b/builtins/alias.def @@ -232,7 +232,11 @@ print_alias (alias, flags) value = sh_single_quote (alias->value); if (flags & AL_REUSABLE) - printf ("alias "); + { + printf ("alias "); + if (alias->name && alias->name[0] == '-') + printf("-- "); + } printf ("%s=%s\n", alias->name, value); free (value); -- 2.1.0