☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 2 months agoLike programming in bashlemmy.mlimagemessage-square24fedilinkarrow-up11arrow-down10
arrow-up11arrow-down1imageLike programming in bashlemmy.ml☆ Yσɠƚԋσʂ ☆@lemmy.ml to Programmer Humor@lemmy.mlEnglish · 2 months agomessage-square24fedilink
minus-squareTangentism@lemmy.mllinkfedilinkarrow-up0·2 months agoYou could write that as 1 line: [ -z "$var" ] && echo "empty" || echo "no it aint"
minus-squareOriel Jutty :hhHHHAAAH:@infosec.exchangelinkfedilinkarrow-up0·2 months agoIncidentally, this is an anti-pattern: http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3
minus-squareOriel Jutty :hhHHHAAAH:@infosec.exchangelinkfedilinkarrow-up0·2 months 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}"
?