Why 0 Is Not a Positional Parameter
“I have read that positional parameters start at $1
(for example: $1
, $2
, $3
and so on are positional parameters). But $0
is not a positional parameter.\r\n\r\nBut why $0
is not a positional parameter?\r\n\r\nI think this could be a reason, but not sure:\r\n\r\nPositional parameters only take their values when a script is executed. For example: if we do ./myScript Hello
, then $1
will have the value Hello
. But $0
can take its value on two occasions: when a script is executed (it would have the value of the script name), and when bash
itself is executed without a script (it would have the value bash
or -bash
).”
<a href=““https://unix.stackexchange.com/questions/412707/why-0-is-not-a-positional-parameter"">— “Steve”