1

I found this line in a bash script:

if [[ -z "$VIRTUAL_ENV" ]]; then
    source ./env/bin/activate
fi

I was wondering what it meant?

(I hope that's not a duplicate question, but it's very hard to google bash commands as they're single letters)

Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134

1 Answers1

2

From man test (link)

It checks whether the string is zero length. In bash there is no distinction between null and empty string, so also returns true if the string has not been set.

Harry Harrison
  • 591
  • 4
  • 12
  • 2
    also documented in `man bash` and `man test` – nos Nov 17 '15 at 23:04
  • 1
    The ABS is a rather poor choice of references -- infrequently updated, and without care to showcasing good practices. Consider the man page, the bash-hackers wiki, or the wooledge wiki instead. – Charles Duffy Nov 17 '15 at 23:16
  • http://wiki.bash-hackers.org/commands/classictest and http://wiki.bash-hackers.org/syntax/ccmd/conditional_expression are good places to start. – Charles Duffy Nov 17 '15 at 23:17
  • @CharlesDuffy - in this case it's the ideal choice of references as it's the first relevant google result (making it the quickest way to find the correct answer). However, I agree in principle that there are much better canonical references for this information, and will now edit my post to reflect that. – Harry Harrison Nov 17 '15 at 23:20
  • If people stopped linking to it, it wouldn't *be* the top google result. – chepner Nov 18 '15 at 01:45