☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 1 day agoLike programming in bashlemmy.mlimagemessage-square19fedilinkarrow-up1171arrow-down11cross-posted to: programmer_humor@programming.dev
arrow-up1170arrow-down1imageLike programming in bashlemmy.ml☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 1 day agomessage-square19fedilinkcross-posted to: programmer_humor@programming.dev
minus-squareTangentism@lemmy.mllinkfedilinkarrow-up3·22 hours agoYou could write that as 1 line: [ -z "$var" ] && echo "empty" || echo "no it aint"
minus-squareOriel Jutty@infosec.exchangelinkfedilinkarrow-up6·20 hours agoIncidentally, this is an anti-pattern: http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3
minus-squareOriel Jutty@infosec.exchangelinkfedilinkarrow-up4·21 hours 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}"
?