bash - Testing empty variables -
i have large number of variables in script, , want script error out if 1 of variables empty.
i know can:
if [[ -z "$var_1" ]] || [[ -z "$var_2" ]] || ... [[ -z "$var_n" ]]; # failure message fi
however, cannot inform user variable empty if in way. there alternative approach above can inform user empty variable?
#!/bin/sh foo=(var_1 var_2 var_n) bar in ${foo[*]} if [[ ! ${!bar} ]] echo $bar empty fi done
Comments
Post a Comment