jrrand...@gmail.com wrote:
function expand_alias() # expand an alias to full command
{
if [ "$1" = "." ]; then
argument="\\$1"
else
argument="$1"
fi
match=$( alias -p | grep -w "alias $argument=" )
if [ -n "$match" ]; then
expanded="`echo $match | sed -e s/[^=]*=// | sed 's/^.\(.*\).$/\1/'`"
else
expanded="$1"
fi
}
---
I could see this being an option, because I can think of times I might want one
or the other...
I might want to know exactly what I typed, (if only to remind me to use an alias
for some long string and save on RSHP (Repetitive-Stress Hit-Points);
But at the same time it would be useful to know what alias(es) were in effect
at the time... (if only the alias was listed!)
so maybe a literal version, followed by (for lines that were 'expanded' by:
"[" <literal expansion> "]"
Of course the same problem arises with 'functions' as they are said to replace
aliases in _almost_ every situation. I.e. do you really want your history file
to be different depending on whether you did
alias ll=ls\ -l
or
function ll { ls -l "$@"}
??
Wouldn't they have a similar effect on the accuracy of your record?
Of course, then my idea of literal expansion would get very messy... providing
a practical reason to not do it for functions... (depends on what your
requirements are )... ;-)