Sample Header Ad - 728x90

Why $0 is not a positional parameter?

15 votes
3 answers
9773 views
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. But why $0 is not a positional parameter? I think this could be a reason, but not sure: Positional 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).
Asked by Steve (897 rep)
Dec 23, 2017, 06:35 PM
Last activity: Jan 19, 2024, 11:15 AM