mainThe GNU Bourne-Again SHell - Support: sr #108708, fix for output of 'alias' command

 
 

sr #108708: fix for output of 'alias' command

Submitter:  None
Submitted:  Sun 21 Dec 2014 01:05:53 AM UTC
Votes: 1
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 25 Mar 2015 02:43:00 PM UTC, comment #1: 

Fixed in devel branch

dualbus@yaqui:~/local/src/gnu/bash$ git log -p -1 -- builtins/alias.def
commit 06c3a57511953d09ac9ea262bc18bfdbcff23fc4
Author: Chet Ramey <EMAIL>
Date:   Wed Mar 25 10:08:06 2015 -0400

    commit bash-20150320 snapshot

diff --git a/builtins/alias.def b/builtins/alias.def
index d720ee4..d2f6319 100644
--- a/builtins/alias.def
+++ b/builtins/alias.def
@@ -232,7 +232,7 @@ print_alias (alias, flags)
 
   value = sh_single_quote (alias->value);
   if (flags & AL_REUSABLE)
-    printf ("alias ");
+    printf ("alias %s", (alias->name && alias->name[0] == '-') ? "-- " : "");
   printf ("%s=%s\n", alias->name, value);
   free (value);

Anonymous
Sun 21 Dec 2014 01:05:53 AM UTC, original submission:  

When an alias is defined with a name that starts with a dash "-", the pure "alias" command incorrectly performs the output

$ alias
alias -='ls -l'


If you feed this command to bash now, it will fail:

$ alias -='ls -l'
bash: alias: -=: invalid option
alias: usage: alias [-p] [name[=value] ... ]

The correct way to define it of course is either to put another alias definition upfront or to use '--':

$ alias -- -='ls -l'

I am attaching a two-line fix for this which of course is very simple, it is a git-format-patch

In principle, if someone manages to define an alias with non-printable characters, the output of 'alias' will be wrong as well, but that would be quite an odd case. The dash, however, is a printable character

I do use an alias that starts with '-', although not exactly for "ls -l"


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by assarbad (Voted in favor of this item)
  • -email is unavailable- added by chet (Updated the item)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There is 1 vote so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-08 assarbad Carbon-Copy- Added assarbad
    2015-11-13 chet StatusNone Done
    2014-12-21 None Attached File- Added 0001-Fix-output-for-an-alias-starting-with-a-dash.patch, #32695

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code