The form quoted in the bash
man page under Paremeter Expansions
3.5.3 Shell Parameter Expansion
${parameter:-word}
If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.
producing
${MY_DATA_VER:-1}
would expand to 1
if MY_DATA_VER
was either unset, or set to the empty string. Your example, however, omits the colon:
${MY_DATA_VER-1}
This is also documented in the man page, although rather obliquely in a single sentence just before the specific operators are documented (from the 4.1 man page):
Omitting the colon results in a test only for a parameter that is unset.
So in your example, the expansion produces 1
if MY_DATA_VER
was never set, or whatever value MY_DATA_VER
has (which could be the empty string) if it is set.
The shift
example simply removes the first $OPTIND-1
shell arguments. For the significance of OPTIND
and a description of how getopts
works, consult the bash
man page or try help getopts
at the bash
prompt.