[gnu.bash.bug] Defining alias

thomas@prosys.ai.mit.edu (Thomas Thyberg) (07/14/89)

Bash version 1.02
SUN 3/60 SUNOS3.5
gcc version 1.35

Hi.

There is something I really would like to be able to do in bash and that is
to write my alias definitions in my .bashrc something like this:

1:
alias \
  'pd=		pushd' \
  'ud=		popd' \
  'back=	cd $OLDPWD' \
  etc...
or
2:
alias \
  'pd		=pushd' \
  'ud		=popd' \
  'back		=cd $OLDPWD' \
  etc...

to make it more readable (I think it gets more readably anyway).
The problem is this;
The second version doesn't work and in the first the leading white space
in the value part of a definition ends up in the alias definition.
eg.  bash$ alias pd
     alias pd="      pushd"

If you allow 1 than I think that could be fixed by stripping the leading 
spaces of 'value' before calling add_alias in alias_builtin.

But I would prefer 2, which probably needs more work.

If this isn't the way of defining ones aliases, please tell me how!

BTW,
Thanks for doing bash! The best shell I have ever used.
--------------------------------------------------------------------
Thomas Thyberg			INET : thomas@prosys.se
Programsystem AB		UUCP : ...!{uunet,mcvax}!sunic!prosys!thomas
Teknikringen 2A			PHONE: +46 (0)13 21 40 40
S-583 30 Linkoping, Sweden	FAX  : +46 (0)13 21 36 35

bfox@AUREL.CALTECH.EDU (Brian Fox) (07/14/89)

   Date: Fri, 14 Jul 89 13:07:19 +0200
   From: thomas@prosys.ai.mit.edu (Thomas Thyberg)

   Bash version 1.02
   SUN 3/60 SUNOS3.5
   gcc version 1.35

   Hi.

   There is something I really would like to be able to do in bash and that is
   to write my alias definitions in my .bashrc something like this:

   1:
   alias \
     'pd=		pushd' \
     'ud=		popd' \
     'back=	cd $OLDPWD' \
     etc...
   or
   2:
   alias \
     'pd		=pushd' \
     'ud		=popd' \
     'back		=cd $OLDPWD' \
     etc...

   to make it more readable (I think it gets more readably anyway).

Gee, you might want to do something like this:

    function alias () {
      local name=$1
      shift
      local value="$*"

      if [ "$name" = "" ]; then
	builtin alias
      elif [ "$value" = "" ]; then
	builtin alias $name
      else
	builtin alias $1="$value"
    }

Now you can type:

alias ls	ls -F
alias -		cd ~-

Brian