nailed IT
nailed IT

Reputation: 111

What does $? mean in a shell if statement?

What is the meaning of the following statement in shell script?

if ($?REGRESS) then
....
endif

from where the given function is taking input from? This is a part of an old script which I am not able to understand.

Upvotes: 0

Views: 7621

Answers (2)

William Pursell
William Pursell

Reputation: 212404

From the csh the man page:

$?name
${?name}
    Substitutes the string `1' if name is set, `0' if it is not.

But stop using csh (obligatory comment for future readers who may have somehow missed the memo that using csh is bad for you health).

Upvotes: 2

atul jha
atul jha

Reputation: 3

$? is a special variable. It stores the exit status of last command. If the last command runs successfully then it will be 0 and some other value for failure.

Upvotes: 0

Related Questions