☆ Yσɠƚԋσʂ ☆ to Programmer Humor@lemmy.mlEnglish • 2 months agoLike programming in bashlemmy.mlimagemessage-square24fedilinkarrow-up11arrow-down10cross-posted to: programmer_humor@programming.dev
arrow-up11arrow-down1imageLike programming in bashlemmy.ml☆ Yσɠƚԋσʂ ☆ to Programmer Humor@lemmy.mlEnglish • 2 months agomessage-square24fedilinkcross-posted to: programmer_humor@programming.dev
minus-square@Tangentism@lemmy.mllinkfedilink0•2 months agoYou could write that as 1 line: [ -z "$var" ] && echo "empty" || echo "no it aint"
minus-squareOriel Jutty :hhHHHAAAH:linkfedilink0•2 months ago@Tangentism @Ephera Did you mean: echo "${var:-empty}${var:+no it aint}" ?
minus-squareOriel Jutty :hhHHHAAAH:linkfedilink0•2 months agoIncidentally, this is an anti-pattern: http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3
You could write that as 1 line:
[ -z "$var" ] && echo "empty" || echo "no it aint"
@Tangentism @Ephera Did you mean:
echo "${var:-empty}${var:+no it aint}"
?
Incidentally, this is an anti-pattern: http://mywiki.wooledge.org/BashPitfalls#cmd1_.26.26_cmd2_.7C.7C_cmd3