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