On Wed, Jul 02, 2008 at 04:23:05PM +0530, Amarendra Godbole wrote:

> The ksh man page reads: "The name of the shell (i.e. the contents of
> $0) is de-termined as follows: if the -c option is used and there is a
> non-option argument, it is used as the name; if commands are being
> read from a file, the file is used as the name; otherwise, the
> basename the shell was called with (i.e. argv[0]) is used.
> 
> The observed behavior is:
> [EMAIL PROTECTED] ~ $] ksh -c "echo $0"
> ksh
> [EMAIL PROTECTED] ~ $]
> 
> Now, according to the above snippet from the man-page, shouldn't the
> output be "echo", and not "ksh"? (echo is the non-option argument, and
> -c is also being used). Or am I messing things up in my mind? Thanks
> in advance for setting my train of thought straight.
> 
> -Amarendra

The invocation you use has no non-option argument, but a 'string' argument:
Check the synopsis:

ksh [-+abCefhiklmnpruvXx] [-+o option] [-c string | -s | file [argument ...]]

Compare this:

[EMAIL PROTECTED]:67]$ ksh -c 'echo $0' A     
A
[EMAIL PROTECTED]:68]$ 

BTW, use single quotes to avoid too-early expansion.

Reply via email to