☆ Yσɠƚԋσʂ ☆ to Programmer [email protected]English • 1 month agoLike programming in bashlemmy.mlimagemessage-square26fedilinkarrow-up1195arrow-down11cross-posted to: [email protected]
arrow-up1194arrow-down1imageLike programming in bashlemmy.ml☆ Yσɠƚԋσʂ ☆ to Programmer [email protected]English • 1 month agomessage-square26fedilinkcross-posted to: [email protected]
minus-square@[email protected]linkfedilink3•1 month agoYou could write that as 1 line: [ -z "$var" ] && echo "empty" || echo "no it aint"
minus-squareOriel Jutty :hhHHHAAAH:linkfedilink6•1 month agoIncidentally, this is an anti-pattern: http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3
minus-squareOriel Jutty :hhHHHAAAH:linkfedilink4•1 month ago@Tangentism @Ephera Did you mean: echo "${var:-empty}${var:+no it aint}" ?
You could write that as 1 line:
[ -z "$var" ] && echo "empty" || echo "no it aint"
Incidentally, this is an anti-pattern: http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3
@Tangentism @Ephera Did you mean:
echo "${var:-empty}${var:+no it aint}"
?