Skip to content

Technical inaccuracies in positional_params.md #37

Description

@wileyhy

Hi,

This page contains a number of errors.

  1. 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."

  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions