can someone explain this?
Printable View
can someone explain this?
"echo" prints the value of its arguments to its output, which is usually the screen. "$status" evaluates to the value of the variable "status". Here's a bash example.
Code:$ status=something
$ echo Hello, World!
Hello, World!
$ echo $status
something
$ status='something else'
$ echo $status
something else
$
so if my main function returns one calling echo $status directly after that will print 1
??
so when will echo $status return 1 when called?
It would, if $status were set -- however, I think the variable you're looking for is $?, in bash at least.Quote:
so if my main function returns one calling echo $status directly after that will print 1
??
From http://tldp.org/LDP/Bash-Beginners-G...ml#table_03_03Quote:
$? Expands to the exit status of the most recently executed foreground pipeline.
how do i set $status??
If you are on an operating system/in a shell where the status environment variable is defined, then yes.
Edit: Google says $status is a C-shell variable; bash uses $? as pointed out below. We may seem smart, but we don't actually have a clue what shell you're running.
because I typed in echo $status and it doesn't print anything, just a blank line
I did the echo $status just directly after I run the main
Well, try $?. If that doesn't work, tell us what shell you are using.
I am using a korn shell
thank you