Hi,
This page contains a number of errors.
- This sentence...
"Here we can see that our command is the first positional parameter ($0) and that each of the strings afterwards are additional positional parameters (here $1 and $2). Generally when we refer to positional parameters we ignore $0 and start with $1."
...states that $0 is a positional parameter, which is incorrect. The GNU Bash manual states in ch. 3.4.1,
"A positional parameter is a parameter denoted by one or more digits, other than the single digit 0."
$0 is listed in ch. 3.4.2, "Special Parameters."
- The text boxes which contain examples of command lines are vague appear to be incorrect as well. For example:
$ sh myscript.sh OneTwoThree
It is a common convention that a commandline begins with the dollar symbol. If that meaning was intended in these code examples, then the explanations are incorrect. In an interactive shell, the string 'sh' would be assigned to the special parameter "$0", and for positional parameters, 'myscript.sh' would be assigned to "$1" and 'OneTwoThree' would be assigned to "$2". The same is true for the following example. "$0" and "$1" remain the same, 'O' is assigned to "$2", and so on for a total of four positional parameters, rather than three.
However, it was possible that the authors intended for something else. If the examples were written as:
$ sh -c 'myscript.sh OneTwoThree'
...then the existing prose descriptions of 'myscript.sh' assigned to "$0", and the rest of it, would accurately reflect the commmand line.
Please let me know and I'd be happy to draft a pull request.
Hi,
This page contains a number of errors.
"Here we can see that our command is the first positional parameter ($0) and that each of the strings afterwards are additional positional parameters (here $1 and $2). Generally when we refer to positional parameters we ignore $0 and start with $1."
...states that $0 is a positional parameter, which is incorrect. The GNU Bash manual states in ch. 3.4.1,
"A positional parameter is a parameter denoted by one or more digits, other than the single digit 0."
$0 is listed in ch. 3.4.2, "Special Parameters."
$ sh myscript.sh OneTwoThree
It is a common convention that a commandline begins with the dollar symbol. If that meaning was intended in these code examples, then the explanations are incorrect. In an interactive shell, the string 'sh' would be assigned to the special parameter "$0", and for positional parameters, 'myscript.sh' would be assigned to "$1" and 'OneTwoThree' would be assigned to "$2". The same is true for the following example. "$0" and "$1" remain the same, 'O' is assigned to "$2", and so on for a total of four positional parameters, rather than three.
However, it was possible that the authors intended for something else. If the examples were written as:
$ sh -c 'myscript.sh OneTwoThree'
...then the existing prose descriptions of 'myscript.sh' assigned to "$0", and the rest of it, would accurately reflect the commmand line.
Please let me know and I'd be happy to draft a pull request.