My bash script bash.sh only contains one line
echo "${abc:=123}"
I learned that := is used to assign default values. So when I run bash.sh abc=abc, I expect the output to be abc.
However, the output is still 123.
Why is that? Am I call the script in the wrong way? Thanks.
abc=abc ./bash.shto setabcas an environment variable instead of a positional argument (which nothing in your script currently reads).#!/bin/bash, it isn't a bash script at all. (#!/bin/shscripts also aren't bash scripts; they're POSIX sh scripts, which is a more restricted language).