Answer the question
In order to leave comments, you need to log in
How to set the $ variable? in si program?
I am writing a shell. In the task, it is necessary that after each launch of other programs through my shell, the value of the $? variable is set. And what I don't understand is how to do it? Will the system itself set this variable or should I somehow write its value with handles?
Answer the question
In order to leave comments, you need to log in
$? is the exit status of the last program.
In C, it corresponds to the value returned by the main function. The normal termination of the program should return 0, each error usually corresponds to its own code.
exit 0 at the end of main()
exiting main causes the program to exit (generally). and the output value of main is placed in the status variable $?
https://man7.org/linux/man-pages/man1/bash.1.html Special Parameters
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question