Quote:
Originally Posted by
usrrenny
Thanks all for replying.
I have to use :$(can't use any other code for suppress output).
Is there a way to get return code while using :$
NO!
As you have been told by ctac_ and by wisecracker, the exit code from the
: command is zero. Always zero. No matter what comes on the line after the leading
:, the exit code from that command line will be zero.
And, NO! you do not have to use the
: command to suppress output from a command substitution. And, with what you have shown us there is no reason to use command substitution at all.
If we knew what you were trying to do (instead of how you think you need to do it), we might be able to make suggestions that would meet your needs. The suggestions ctac_ and wisecracker supplied seem to meet your requirements as they have been stated:
- run your script named return.sh,
- discard any output sent to standard output by return.sh, and
- print the exit code returned by return.sh.
Although the code suggested by ctac_ more correctly represents the output that would be produced by the
: command with a command substitution that failed. The
: command redirects output directed to standard output by a command substitution to
/dev/null, but it does not discard output directed to standard error output by a command substitution like the code suggested by wisecracker does.