Ac3_DeXt3R Ac3_DeXt3R - 2 months ago 4
Bash Question

Behaviour of 'ECHO' in csh and bash

I was writing few scripts and suddenly stroke me to think the following commands in CSH and BASH shells.

In csh shell

$ echo $?BASH
$ echo $?HOME
$ echo $? home
0 home

In bash shell

$ echo $?BASH
$ echo $?HOME
$ echo $? home
0 home

Someone explain the above behaviour. I know the echo $? prints the exit status of the last command but if added with some string then how its working?


If you review the documentation csh indicates:

Substitutes the string 1 if the variable name is set, 0 if it is not.

Substitutes 1 if the current input file name is known, 0 if it is not.

be careful, $? is diferent to $?name