Taken from FreeBSD's man page on sh (because its the most convenient online, target platform is Debian if it matters):
SH(1) FreeBSD General Commands Manual SH(1)
NAME
sh -- command interpreter (shell)
SYNOPSIS
sh [-/+abCEefhIimnPpTuVvx] [-/+o longname] [script [arg ...]]
sh [-/+abCEefhIimnPpTuVvx] [-/+o longname] -c string [name [arg ...]]
sh [-/+abCEefhIimnPpTuVvx] [-/+o longname] -s [arg ...]
...
I'm particularly interested in the use case of:
sh [-/+abCEefhIimnPpTuVvx] [-/+o longname] -c string [name [arg ...]]
Example:
# Normal:
myscript hello world
myscript hello world >/var/log/myscript.combined 2>&1
Constrained:
- Arguments 'hello' and 'world' are suffixed by calling program.
myscript >/var/log/myscript.combined 2>&1 hello world
Constrained Further:
- Wrapped in sh
to catch system messages, like Segmentation Fault
sh -c 'myscript $@' _ >/var/log/myscript.combined 2>&1 hello world
I noticed that the first argument was not passed to myscript
, and the documentation alludes to a name
parameter, that I didn't see a doc section on. In my example I have added ad _
in place of the name argument, but:
command_name
argument – myrdd May 07 '18 at 14:31