☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 4 days agoLike programming in bashimagemessage-square20fedilinkarrow-up1181arrow-down11
arrow-up1180arrow-down1imageLike programming in bash☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 4 days agomessage-square20fedilink
minus-squareTangentism@lemmy.mllinkfedilinkarrow-up3·4 days agoYou could write that as 1 line: [ -z "$var" ] && echo "empty" || echo "no it aint"
minus-squareOriel Jutty@infosec.exchangelinkfedilinkarrow-up6·4 days agoIncidentally, this is an anti-pattern: http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3
minus-squareOriel Jutty@infosec.exchangelinkfedilinkarrow-up4·4 days 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}"
?