by dllthomas · 12y ago · 0 comments
In the rm line of the snippet above, "/some/location". Magic variables in bash tend to lose their magic once set.
In Bash, it doesn't do anything useful.
> In Bash, it doesn't do anything useful.
In sh and derived shells, it sets the arguments ($1, $2, and so on). In this case you end up with $1 being ‘HOME’, $2 being ‘=’, and $3 being ‘/some/location’.on IRIX, $HOME for root is almost certainly root. So the resulting command is rm -rf /
What I said about un-magic-ing is true for sure. "HOME=foo; echo $HOME" will print "foo".
Interestingly, it's propagated. "HOME=foo sh -c 'echo $HOME'" will also print "foo".