With the following bash function, how can I get the function allow $2 to be optional, defaulting its value when nothing is passed for that argument ?
serputil ()
{
local opstring="$1"
local sersel="$2"
}
bash
parameter expansion:iserputil () {
local opstring="$1"
local sersel="${2:-DEFAULT}"
echo "$opstring"
echo "$sersel"
}
iserputil ok
ok
DEFAULT
If you run
iserputil ok ko
You will get
ok
ko