🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #707

Re: Request for enhancement

#707
From: Chet Ramey
Date: Tue, 14 Nov 1989 15:32
45 lines
2263 bytes
In article <127462@sun.Eng.Sun.COM> bitbug (James Buster) writes:
>I believe it would be useful to add the following construct to bash shell
>functions, similar in spirit to 'builtin': 'external'.
>The syntax is just like builtin, i.e:
>
>function ls () {
>    external ls -FC $*
>}

I still don't see what's wrong with this:

ls()
{
	/bin/ls -FC "$@"
}

Jeez, a couple of extra characters when typing in the function...

Seriously, I can see a need for some mechanism that will let people who
insist on writing functions like this use the $PATH.  I'm not sure a new
keyword is the way to go, though.  Maybe something like "only non-quoted
words are scanned as possible function names", which is the way aliases
are expanded.  However, I'm not sure I like that any better.  (I just took
a few minutes, put it into bash, made sure it works, and then took it out
again.  It's pretty easy to do.)   Anyone else have ideas?

>I would also like to report what I consider a bug in bash: aliases
>are expanded when a shell function is defined. I believe the correct
>behavior is to expand aliases when the shell function is executed,
>rather than when it is defined.

Well, bash does aliases the way ksh does aliases, and this is the way that
ksh aliases are defined to behave.  When you think about it, it makes some
sense, and it's wrong to do it the other way.  Function definitions are
executable bash statements (a function definition installs the function and
returns success or failure as appropriate), and aliases are expanded in
executable statements.

Chet

-- 
Chet Ramey
Network Services Group				"Where's my froggie?"
Case Western Reserve University
chet@ins.CWRU.Edu			
Technical Details
Message-ID: <891@cwjcc.CWRU.Edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!snorkelwacker!tut.cis.ohio-state.edu!rpi!uwm.edu!uakari.primate.wisc.edu!samsung!rex!ukma!cwjcc!cwns1!chet
References: <127462@sun.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!snorkelwacker!tut.cis.ohio-state.edu!rpi!uwm.edu!uakari.primate.wisc.edu!samsung!rex!ukma!cwjcc!cwns1!chet
From: chet@cwns1.CWRU.EDU (Chet Ramey)
Newsgroups: gnu.bash.bug
Subject: Re: Request for enhancement
Message-ID: <891@cwjcc.CWRU.Edu>
Date: 14 Nov 89 15:32:32 GMT
References: <127462@sun.Eng.Sun.COM>
Sender: news@cwjcc.CWRU.Edu
Reply-To: chet@po.CWRU.Edu (Chet Ramey)
Distribution: gnu
Organization: Case Western Reserve Univ. Cleveland, Ohio, (USA)
Lines: 45