Skip to content

Files

Latest commit

 

History

History
34 lines (23 loc) · 664 Bytes

SC2270.md

File metadata and controls

34 lines (23 loc) · 664 Bytes

Pattern: Missing use of set -- first second ..

Issue: -

Description

You have a command on the form $2=value.

If the goal is to assign a new value to the positional parameters, use the set builtin: set -- one two .. will cause $1 to be "one" and $2 to be "two".

If you instead want to compare the value, use [ ] and add spaces: [ "$1" = "foo" ]

Example of incorrect code:

if [ -z "$1" ]
then
  $1="help"
fi

Example of correct code:

if [ -z "$1" ]
then
  set -- "help"
fi
true

Further Reading