Thread View: gnu.bash.bug
2 messages
2 total messages
Started by Thomas Thyberg
Fri, 14 Jul 1989 11:07
Defining alias
Author: Thomas Thyberg
Date: Fri, 14 Jul 1989 11:07
Date: Fri, 14 Jul 1989 11:07
44 lines
1665 bytes
1665 bytes
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
Defining alias
Author: Brian Fox
Date: Fri, 14 Jul 1989 13:18
Date: Fri, 14 Jul 1989 13:18
50 lines
1432 bytes
1432 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads