Why Nostr? What is Njump?
2024-04-25 16:12:29

Simon Tatham on Nostr: In bash, writing ${var?} instead of just ${var} or $var means if var isn't defined ...

In bash, writing ${var?} instead of just ${var} or $var means if var isn't defined then bash will throw an error and _not_ execute your command, instead of expanding it to "" and carrying on.

mv file1 file2 $subdir # oops, I overwrote file2
mv file1 file2 ${subdir?} # error message instead of disaster

My favourite use of this is for example commands in documentation, with placeholders for the user to fill in. Then it's OK if a user accidentally copy-pastes it _without_ filling them in!
Author Public Key
npub1r80xhdf7fpspq6m6jtjhl0kpemmyy9jv86lqcaht32eccfe8vuhsg89e8g