lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Shell scripting bafflement


From: Greg Chicares
Subject: [lmi] Shell scripting bafflement
Date: Wed, 26 Feb 2020 22:27:11 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

Vadim--Sorry to bother you with this, but I just can't see why
these two nearly-identical commands behave oppositely, and I'm
sure you'll know why.

This does exactly what I expect, as [non]gnu.org is certainly
reachable on my machine:

/home/greg[0]$if curl https://git.savannah.nongnu.org:443 >/dev/null 2>&1 ; 
then      
  echo true
else
  echo false
fi

true

But if I enclose the command in "[ $(...) ]", it "fails":

/home/greg[0]$
/home/greg[0]$if [ $(curl https://git.savannah.nongnu.org:443 >/dev/null 2>&1) 
]; then
  echo true
else
  echo false
fi

false


reply via email to

[Prev in Thread] Current Thread [Next in Thread]