zephyr@lemmy.worldM to linuxmemes@lemmy.world · 1 year agoWhich way do you expand variables?lemmy.worldexternal-linkmessage-square21fedilinkarrow-up1102arrow-down12
arrow-up1100arrow-down1external-linkWhich way do you expand variables?lemmy.worldzephyr@lemmy.worldM to linuxmemes@lemmy.world · 1 year agomessage-square21fedilink
minus-squareRazorsLedge@lemmy.worldlinkfedilinkarrow-up24·edit-21 year agofoo=ding foobar=dong echo \$foobar Brackets make it explicit what you’re trying to do. Do you want “dingbar” or do you want “dong”? I forget what the actual behavior is if you don’t use brackets here, because I always use brackets for this reason now
minus-squaresubtext@lemmy.worldlinkfedilinkarrow-up5·1 year agoI believe the actual behavior here would be printing “dong” as the shell interpreter is greedy in its evaluation of variables.
minus-squarevrighter@discuss.tchncs.delinkfedilinkarrow-up2·1 year agothe actual behavior here is to echo the literal string “$foobar”, because the $ sign is escaped. so no variable expansion will take place at all.
minus-squareRazorsLedge@lemmy.worldlinkfedilinkarrow-up2·1 year agoOh lol. It doesn’t show the $ at all on my mobile app till I escaped it
minus-squarevrighter@discuss.tchncs.delinkfedilinkarrow-up2·1 year agoah, so it’s up to the client. I’m using jerboa, in this case
foo=ding foobar=dong echo \$foobar
Brackets make it explicit what you’re trying to do. Do you want “dingbar” or do you want “dong”? I forget what the actual behavior is if you don’t use brackets here, because I always use brackets for this reason now
I believe the actual behavior here would be printing “dong” as the shell interpreter is greedy in its evaluation of variables.
the actual behavior here is to echo the literal string “$foobar”, because the $ sign is escaped. so no variable expansion will take place at all.
Oh lol. It doesn’t show the $ at all on my mobile app till I escaped it
ah, so it’s up to the client. I’m using jerboa, in this case