bash - Test if user passed in a shell variable -
i have shell function check if user passed in second variable. have tried not seem working
function dash() { if [ -z "$2" ]; open dash://$1:$2; else open dash://$1; fi } basically, want if second argument $2 passed in 'x' else 'y'
just do:
function dash() { open dash://$1${2+:}$2 } the ${2+:} expands : if $2 set, , null string otherwise.
Comments
Post a Comment