Wednesday, December 12, 2007

Shell script code

See Advanced bash scripting guide by Mendal Cooper. In reality, it is simple enough document so that beginners can start.

Things that I recollected today is special exit codes, 1 - catchall for general errors, 126 - command invoked can not execute, permission denied or command can not execute, 127 - command not found, 128 + n - signal number recieved, 255 - exit status out of range.

$ let var=1/0
bash: let: var=1/0: division by 0 (error token is "0")
$echo $?
1

$./directoryname
bash: ./directory: is a directory
$ echo $?
126

$ unknowncommand
bash: unknowncommand: command not found
$ echo $?
127

$ vim somefile
ctrl-z
[1]+ Stopped vim
echo $?
148

No comments: