m4: Sysval
1
1 13.4 Exit status
1 ================
1
1 To see whether a shell command succeeded, use 'sysval':
1
1 -- Builtin: sysval
1 Expands to the exit status of the last shell command run with
1 'syscmd' or 'esyscmd'. Expands to 0 if no command has been run
1 yet.
1
1 sysval
1 =>0
1 syscmd(`false')
1 =>
1 ifelse(sysval, `0', `zero', `non-zero')
1 =>non-zero
1 syscmd(`exit 2')
1 =>
1 sysval
1 =>2
1 syscmd(`true')
1 =>
1 sysval
1 =>0
1 esyscmd(`false')
1 =>
1 ifelse(sysval, `0', `zero', `non-zero')
1 =>non-zero
1 esyscmd(`echo dnl && exit 127')
1 =>
1 sysval
1 =>127
1 esyscmd(`true')
1 =>
1 sysval
1 =>0
1
1 'sysval' results in 127 if there was a problem executing the command,
1 for example, if the system-imposed argument length is exceeded, or if
1 there were not enough resources to fork. It is not possible to
1 distinguish between failed execution and successful execution that had
1 an exit status of 127, unless there was output from the child process.
1
1 On UNIX platforms, where it is possible to detect when command
1 execution is terminated by a signal, rather than a normal exit, the
1 result is the signal number shifted left by eight bits.
1
1 dnl This test assumes kill is a shell builtin, and that signals are
1 dnl recognizable.
1 ifdef(`__unix__', ,
1 `errprint(` skipping: syscmd does not have unix semantics
1 ')m4exit(`77')')dnl
1 syscmd(`kill -9 $$')
1 =>
1 sysval
1 =>2304
1 syscmd()
1 =>
1 sysval
1 =>0
1 esyscmd(`kill -9 $$')
1 =>
1 sysval
1 =>2304
1