[Top][All Lists]

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

[Help-bash] Evaluations of backticks in if statements

From: Ryan Marples
Subject: [Help-bash] Evaluations of backticks in if statements
Date: Thu, 23 Feb 2017 01:01:30 +0000


I’ve seen bash statements like the following: if `cmd` …

This appears to run the body of the if when cmd exits successfully. But I don’t 
understand the mechanics of why. My understanding is that `cmd` (assuming in 
this case cmd prints nothing to either stdout nor stderr but exits 
successfully) should evaluate to an empty string, and then you’d be saying if 
“” … which should be false.

Please enlighten be as to why `cmd` in the context of if `cmd` means “the exit 
code of cmd” rather than “the output of cmd”.


reply via email to

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