bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with list of aliases


From: Pedro Gimeno
Subject: Problem with list of aliases
Date: Tue, 14 Mar 2017 17:56:12 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Icedove/24.7.0

When using the 'alias' command without parameters, or with the '-p' parameter, 
a list of aliases is displayed. This list has the form:

  alias name='value'

'help alias' states that this form is 'reusable', thus implying, if I 
understand it correctly, that it can be fed back to bash.

But that's not always the case. I have an alias called '-' that resolves to 'cd 
-'. This alias needs to be entered as follows:

  alias -- -='cd -'

However, it is output by the 'alias' command as:

  alias -='cd -'

And when that line is input to bash, it produces an error:

  bash: alias: -=: invalid option
  alias: usage: alias [-p] [name[=value] ... ]

This can be easily fixed with sed to ensure the output is compatible with bash:

  alias -p | sed 's/^alias -/alias -- -/'

Therefore, either the docs need to be fixed (by adding a caveat, perhaps 
suggesting the 'sed' workaround, or by omitting 'reusable'), or the output of 
'alias -p' should include '--' when the alias name starts with '-'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]