|
|
|
|
|
by jiffytick
4101 days ago
|
|
or check the variable before using it, like any other programming language: [[ "$VAR" ]] && rm -rf "$VAR/*" I think most of these issues stem from the fact that most developers that write shell scripts don't actually understand what they're doing, treating the script as a necessary annoyance rather than a component of the software. |
|
Anyways, that is not anything like other programming languages. Checking in that way is error prone and not really an improvement (nor equivalent to set -o).
See what I did there? It's an rm -rf /* bug because "checking variables" is not the answer.In other programming languages, if an identifier is mis-typed things will blow up. E.g., in ruby if I write:
I get "NameError: undefined local variable or method `deamon_path`"These issues do not always stem from bad developers. Bash's defaults are not safe in many ways and saying "people should just check the variable" isn't helpful here.