0.5.13.5: unwanted alias expansions
Steffen Nurpmeso <[email protected]>
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <20260810214025.uEv9z5qG@steffen%sdaoden.eu> |
Hello.
I have a quite clumsy script environment with ~/.profile, ~/.shrc,
~/.bash_logout etc that i try to use for all shells. Tried at
least, for many years, now for some time have only bash, dash via
Linux distribution. Anyhow. Imagine ~/.shrc doing among others
[ -f "$HOME/.shared.alias" ] && . "$HOME/.shared.alias"
and that doing
___aa l '\command ls ${LS_COLOUR_FLAG} -aFtr'
where that comes from .shrc again and is
if [ -n "$___SHTYPE" ] || ( type alias | grep 'builtin\|built-in\|intrinsic') >/dev/null 2>&1; then
___a() { alias "$1"="$2"; }
___aa() { alias "$1"="$2"; }
___ua() { unalias "$1"; }
else
echo
echo ' *No alias support, aliases will be shell functions!*'
[skip]
fi
so that. Now after
___aa l '\command ls ${LS_COLOUR_FLAG} -aFtr'
again, with debug instrumentation:
echo ALI-0
i= j= k= l=
echo ALI-1
if (ps -o user,pid,ppid,ni,%cpu,sz:6,rss:6,stat,time,stime,tty,cmd) >/dev/null 2>&1; then
k='-o user,pid,ppid,ni,%cpu,sz:6,rss:6,stat,time,stime,tty,cmd'
echo ALI-2
elif ( ps -F ) >/dev/null 2>&1; then
k=-F
elif ( ps -f ) >/dev/null 2>&1; then
k=-f
else
k='-o user,pid,pcpu -o args'
fi
echo ALI-3
(ps -e $k) >/dev/null 2>&1 && l=-e || l=-A
echo ALI-4
So in dash context:
#?0|lecce:tmp$ dash -i
shrc
0 is dash
JA
ALI-0
../ .system-hook-1 .ICE-unix/ .X11-unix/ .X0-lock tmux-1000/ .pkgmk/ .nail/ cron.MXurmD/ ./ s-nail-edbaseuR2PSP
ALI-1
ALI-2
ALI-3
../ .system-hook-1 .ICE-unix/ .X11-unix/ .X0-lock tmux-1000/ .pkgmk/ .nail/ cron.MXurmD/ ./ s-nail-edbaseuR2PSP
ALI-4
what we see is actually two times the expansion of the l alias.
Which for completeness sake is reported as
#?0|lecce:tmp$ alias l
'l=\command ls ${LS_COLOUR_FLAG} -aFtr'
whereas in bash it is
alias l='\command ls ${LS_COLOUR_FLAG} -aFtr'
By the way i also see from the ~/.bash_logout which is called via
___on_exit() {
echo on exit
[ -f "$HOME/.bash_logout" ] && . "$HOME/.bash_logout"
}
trap ___on_exit EXIT
#?0|lecce:tmp$
on exit
Logging out ... and:
(a) Cleanup.
(*) Do nothing but logging out.
Three seconds to go, choose or loose ...
Ttwo
Ciao and out
that i cannot input anything in the above that really is
if (echo|read -t 1) >/dev/null 2>&1; then
echo ein
read -t 3 input
else
echo Ttwo
PROCID=$$
export PROCID
trap "echo 'Timeout expired'; exit 0" QUIT
/bin/sh -c '/bin/sleep 3 && kill -QUIT $PROCID' </dev/null >/dev/null 2>&1 &
killer=$!
read input
kill -TERM $killer
fi
whereas bash let's me input something.
Like i said this shell environment is way over two decades old,
with rewrites, sure, but it used to work with quite some shells
say before Corona or so.
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)