Skip to main content

Timeline for How to check if env exist in bash?

Current License: CC BY-SA 4.0

6 events
when toggle format what by license comment
Apr 15 at 7:40 comment added Seamus Maybe worth a mention that if testing a variable (e.g. VAR) against -v, the variable name must not be expanded; i.e. if [[ ! -v VAR ]]; then echo "unset"; fi instead of if [[ ! -v $VAR ]]; then echo "unset"; fi. REF
Apr 14 at 15:23 comment added Jetchisel declare -x should show them all.
Apr 14 at 13:13 comment added Stéphane Chazelas Note that having an empty value (like after VAR=) is not the same as having no value (like after unset -v VAR; export VAR or VAR=()).
Apr 14 at 13:11 comment added Stéphane Chazelas env | grep -q '^VAR=' could give false positives if there are environment variables whose values contain \nVAR=.
Apr 14 at 12:32 vote accept kj-crypto
Apr 14 at 12:01 history answered jesse_b CC BY-SA 4.0