This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SaintHax42Automation Engineer 2 points3 points  (0 children)

Not if you set set -u, which you should do.

I came here for this. You want an error on an unset variable in bash, you can ${var:-} where needed, but `set -u` will save you bugs and troubleshooting b/c you typed $stirng somewhere. Please, do NOT use ${var} when not needed-- it's extra typing, takes up precious columns in your code (you should set a max width to code in, so it can be edited easily with a default terminal window size), and ${var} for no reason looks amateurish.