bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does this work


From: Chet Ramey
Subject: Re: Why does this work
Date: Wed, 30 Jan 2002 08:39:31 -0500

> > > - Why does this work with bash but not with ksh?
> > Which part?
> 
> Why remains $0 the same in a function with bash but not with ksh?

Bash does it because POSIX.2 says it should.  That's why bash makes
sure the FUNCNAME variable exists and is set to the name of any
currently-executing function.

ksh93 has two styles of shell functions:  `posix' functions, which 
are declared as `name()', and `ksh' functions, which are declared as
`function name'.  As far as I can tell, ksh93 sets $0 to the script
name in `posix' functions, and sets $0 to the function name in
`ksh' functions.

> It's not easy the write scripts that run with any shell...

Nope, it's not.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    chet@po.CWRU.Edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]