-
Notifications
You must be signed in to change notification settings - Fork 1.9k
SC2270
Joachim Ansorg edited this page Nov 12, 2021
·
2 revisions
if [ -z "$1" ]
then
$1="help"
fior
if $1="help"
then
echo "Usage: $0 filename"
fiif [ -z "$1" ]
then
set -- "help"
fior
if [ $1 = "help" ]
then
echo "Usage: $0 filename"
fiYou 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" ]
None
- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!