Is there a standard Unix command that does something similar to my example below
$ <cmd here> 56
$ echo Return code was $?
Return code was 56
$
<cmd here> should be something that can be fork-execed and leaves 56 as the exit code when the process exits. The exit and return shell builtins are unsuitable for what I'm looking for because they affect the invoking shell itself by exiting out of it. <some cmd> should be something that I can execute in non-shell contexts - e.g., invoking from a Python script with subprocess.
E.g., /usr/bin/false always exits immediately with return code 1, but I'd like to control exactly what that return code is. I could achieve the same results by writing my own wrapper script
$ cat my-wrapper-script.sh # i.e., <some cmd> = ./my-wrapper-script.sh
#!/usr/bin/bash
exit $1
$ ./my-wrapper-script.sh 56
$ echo $?
56
but I'm hoping there happens to exist a standard Unix command that can do this for me.
exitis the only one I can think of, but it tends to end your shell.bash -c 'exit 56'orbash -c "exit $1"might work for you.(exit 56)?trueandfalsebuilt-ins if you need to return 0 or 1.