With bash, you use an array, and all variables must be properly quoted:
ARG1="foo bar baz" ARG3="qux" cmd=( mycmd ) [[ -n "$ARG1" ]] && cmd+=( "$ARG1" ) [[ -n "$ARG2" ]] && cmd+=( "$ARG2" ) [[ -n "$ARG3" ]] && cmd+=( "$ARG3" ) printf "%s\n" "$" #exec "$"
This will give you the invocation you want: exec mycommand "foo bar baz" qux
with no "empty string" arguments. Remove the printf line and uncomment the exec line if you're happy with how it's working.