🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.unix
Article #171

POSIX alias expansion bugs (in bash 1.05)

#171
From: Moderator, John S. Quarterman
Date: Fri, 16 Mar 1990 22:39
72 lines
2892 bytes
From: Maarten Litmaath <uunet!cs.vu.nl!maart>

In article <1990Mar16.194728.21389@usenet.ins.cwru.edu> of the newsgroup
gnu.bash.bug, chet@cwns1.CWRU.EDU (Chet Ramey) writes:
)...
)Sorry Maarten, it's not a bug.  It's how aliases are defined to behave.  The
)part I left out (because it's come up here before) is that aliases are 
)expanded when a command is *read*, not when it is executed.  Call that a
)design error, if you like, but bash and ksh do it the same way.

Conclusion: sometimes a `;' and a newline are NOT equivalent.  `Of course',
you might say, but I maintain it's a design bug, because of the unexpected
results.  Why can I say

	for i in *; do foo; done

instead of

	for i in *
	do foo
	done

but not

	alias foo=bar; foo

instead of

	alias foo=bar
	foo

?

)...  Alias expansion is done
)when the command line is tokenized (at least it should be, and I have
)redone expansion so it is -- vanilla bash does expansion on whole lines at
)a time).  So all aliases get expanded before any `alias' commands are
)executed.  [...]

I say: divide the line in logical commands and execute them in turn,
expanding aliases and functions at execution time.  That's far more natural
and I don't think it's much more difficult to program.

)>Bourne shell functions have the correct behavior.
)
)Bourne shell functions are not a complete replacement for bash/ksh aliases;
)they never will be.  It's possible, for instance, to write an alias
)`remote' such that 'remote x ls -l /bin/*' will pass its arguments to a
)remote machine x for evaluation; that's not possible with functions because
)globbing is done before the function is called.  [...]

Ridiculous!  If I say

	command /bin/*

then I don't want behavior dependent on the nature of `command'!
That's precisely the bug recently discussed in comp.unix.questions:

	$ x=external
	$ x=internal pwd >/dev/null
	$ echo "pwd is an $x command in this version of the shell"

You do NOT repeat NOT want to make the same mistake again!
(And POSIX neither.)

If I want argument evaluation on the remote machine, I will quote the
arguments, thank you!
--
 1) Will 4.5BSD have wait5()?         |Maarten Litmaath @ VU Amsterdam:
 2) Sleep(3) should be sleep(2) again.|maart@cs.vu.nl, uunet!mcsun!botter!maart

Volume-Number: Volume 19, Number 13
Technical Details
Message-ID: <582@longway.TIC.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!usenet.ins.cwru.edu!tut.cis.ohio-state.edu!cs.utexas.edu!longway!std-unix

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!usenet.ins.cwru.edu!tut.cis.ohio-state.edu!cs.utexas.edu!longway!std-unix
From: std-unix@longway.TIC.COM (Moderator, John S. Quarterman)
Newsgroups: comp.std.unix
Subject: POSIX alias expansion bugs (in bash 1.05)
Message-ID: <582@longway.TIC.COM>
Date: 16 Mar 90 22:39:26 GMT
Reply-To: Maarten Litmaath <uunet!cs.vu.nl!maart>
Organization: VU Informatika, Amsterdam, the Netherlands
Lines: 72
Approved: jsq@longway.tic.com (Moderator, John S. Quarterman)