3 ms·
This is not accurate. If the download gets interrupted bash will execute the partial line. That means `rm -r /tmp/foo.ext` or `rm -r ${HOME}/.tmp_config` can ex
by godelski 3y ago
This is not accurate. If the download gets interrupted bash will execute the partial line. That means `rm -r /tmp/foo.ext` or `rm -r ${HOME}/.tmp_config` can execute as `rm -r /`.
This can be mitigated by wrapping the script, but clearly no one is looking at the code so this isn't really verified anyways. And it's not like we see that all the time.
Edit:
But my main point is about habits. There's the concern mananaysiempre brings up[0], but either way, it is best to be in good habits.
[0] https://news.ycombinator.com/item?id=39554895 https://news.ycombinator.com/item?id=39554895
- _joel 3y agoFrom the post curl -sL -H "Accept: text/roff" https://jamesg.blog/2024/02/28/programming-projects/ https://jamesg.blog/2024/02/28/programming-projects/ > post.page && man ./post.page If curl's process is interupted, it'll generate a non-0 exit code and the man command won't be exectued. That's how double ampersands work in shell.
- godelski 3y agoI think you've missed the context of my comment. We're talking about `curl | man` not `curl && man`. You're right, `&&` doesn't have that risk. But `|` sure does.
- fragmede 3y agothankfully rm -r / doesn't work on modern systems, though that doesn't invalidate your point.
- godelski 3y agoOn what system are you talking about? I mean it won't kill everything because sudo but everything you have permissions to are still in danger
- prmoustache 3y agoWhich usually include your most valuable data. Nobody cares about losing a system. This is the data it is hosting that is valuable and takes the most time to recover from a backup.
- fragmede 3y agoOn modern, sane systems (meaning those running GNU coreutils, which doesn't include os x iirc), rm -rf / will refuse to run unless --no-preserve-root is also specified. https://www.gnu.org/software/coreutils/manual/html_node/Treating-_002f-specially.html https://www.gnu.org/software/coreutils/manual/html_node/Trea...