diff --git a/boxctl.sh b/boxctl.sh index da15b17..5037112 100755 --- a/boxctl.sh +++ b/boxctl.sh @@ -208,6 +208,35 @@ _ssh() { fi } +if_optval() { + local _a=$1 _b=$2 _c + + if [ ! -z $3 ]; then + _c=$3 + else + _c="" + fi + + _a=${_a%%\"} + _a=${_a##\"} + + _b=${_b%%\"} + _b=${_b##\"} + + _c=${_c%%\"} + _c=${_c##\"} + + if [ "${_b}" != "" ]; then + echo "${_a} ${_b}" + else + if [ "$_c" != "" ]; then + echo "${_a} ${_c}" + else + echo "" + fi + fi +} + V=$(expand_v) fnc() { @@ -239,20 +268,34 @@ fi if [ -f ./users ]; then msg 0 "adding $(fnc users)" for user in $(cat users | grep -v ^#); do - local _u _uid _gid _c _home _shell _pass - read _u _uid _gid _c _home _shell _pass <