Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
1–10 of 280 posts
Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
#2 $(cd "${0%/*}")Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
#3 # figure out the absolute path to the script being run a bit
# non-obvious, the ${0%/*} pulls the path out of $0, cd's into the
# specified directory, then uses $PWD to figure out where that
# directory lives - and all this in a subshell, so we don't affect
# $PWD
STEAMROOT="$(cd "${0%/*}" && echo $PWD)"
[...]
# Scary!
rm -rf "$STEAMROOT/"*
The programmer knew the danger and did nothing but write the "Scary!" comment. Sad, but all-too-familiar.Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
#4What is this magic doing? $(cd "${0%/*}")
Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
#5 # Scary!
rm -rf "$STEAMROOT/"*
Anybody who writes a line like this deserves their software engineer license revoked. This isn't the first time I've seen shit like this (I've seen it in scripts expected to be run as root, no less); it makes my blood boil.Seriously. "xargs rm -df -- EDIT: I shouldn't be so harsh, if it weren't for the comment admitting knowing how poor an idea this line is.
Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
#6What is this magic doing? $(cd "${0%/*}")
"the ${0%/*} pulls the path out of $0, cd's into the specified directory, then uses $PWD to figure out where that directory lives - and all this in a subshell, so we don't affect $PWD"
So for example, that would take /user/amputect/seam_setup.sh and change directories into into /user/amputect.
Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
#7"set -o errexit -o nounset -o pipefail"
It'll save you headaches.
Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
#8I like the 3-2-1 rule:
At least three copies,
In two different formats,
with one of those copies off-site.
Software is written by humans who will undoubtably miss a corner case and not think of every possible environment.Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
#9The transition from meware to software is a hard one - and usually it's how we get terrible reputations as an industry. Basically it's a prototype till it's burned enough beta users.
Edit OMG - that is actually Steam from valve - I take it back - this is supposed to be software.
Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user
#10What is this magic doing? $(cd "${0%/*}")
$0 is the path of the script. ${0%/* } takes $0, deletes the smallest substring matching /* from the right (the filename) and returns the rest, which would be the directory of the script. So this changes the directory to the directory the script is located in.