Earlier quoted context omitted.
And this is why it is important to write something like set -eu on top of your bash scripts -- execution will stop on errors (non-zero retvals) and on undefined variables.
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.
Bug 1202858 – Restarting squid results in deleting all files in hard-drive
81–90 of 179 posts
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#82Earlier quoted context omitted.
And this is why it is important to write something like set -eu on top of your bash scripts -- execution will stop on errors (non-zero retvals) and on undefined variables.
I wonder why set -eu is not the default setting.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#83My good old trick to mitigate that is: touch /-@ I also always do it in my home directory: touch ~/-@ That's the first thing I do on a new host. When accidentally running rm -f *, the command expands to -@ first, which is not a valid option and makes the command fail before doing any harm rm: illegal option -- @ usage: rm [-f | -i] [-dPRrvW] file ...
Or just use zsh.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#84My good old trick to mitigate that is: touch /-@ I also always do it in my home directory: touch ~/-@ That's the first thing I do on a new host. When accidentally running rm -f *, the command expands to -@ first, which is not a valid option and makes the command fail before doing any harm rm: illegal option -- @ usage: rm [-f | -i] [-dPRrvW] file ...
Or just use zsh.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#85Earlier quoted context omitted.
Well, the bug was reported against RHEL 6.7 which has not been released yet.
RH don't have a great reputation here. Unlike Debian which does proper triage and practices "zero release-critical bugs", RH threw out RHEL7 with loads of critical issues still open.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#86Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#87Earlier quoted context omitted.
Ahh Redhat, the distro which chose to symlink a bunch of binary lib files from Apache into the etc directory. "Why is grepping /etc taking so long? Binary files in /etc?!? WTF?!?" Coming from Debian, Redhat seems to make a lot of irk-worthy choices.
I find the /etc/httpd/logs symlink more annoying. If you want to grep through your Apache configuration you have to explicitly grep through conf and conf.d otherwise just going to /etc/httpd and doing a grep -r you're searching through gigs of Apache logs.
-d, --directories=ACTION how to handle directories;
ACTION is 'read', 'recurse', or 'skip'
-D, --devices=ACTION how to handle devices, FIFOs and sockets;
ACTION is 'read' or 'skip'
-r, --recursive like --directories=recurse
-R, --dereference-recursive likewise, but follow all symlinksRe: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#88Earlier quoted context omitted.
Pretty terrible that such a thing is even allowed by Windows. This is why as a user I like Apple's OS X sandbox.
Similar things have happened on OS X: http://apple.slashdot.org/story/01/11/04/0412209/itunes-20-i...
This is a bug from 15 years ago, much much before the sandbox feature was introduced.
A sandboxed iTunes would have prevented that.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#89Earlier quoted context omitted.
Or just use zsh.
Would zsh still protect me if the script explicitly uses Bash (i.e. #!/bin/bash)? Sorry if this is a dumb question, I'm unsure how shells work when calling other kinds of shell scripts.
Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive
#90Earlier quoted context omitted.
Agreed, I should've elaborated. All it takes is something like this in the init script without checking if the variable is empty: rm -rf "$STEAMROOT/"*
And this is why it is important to write something like set -eu on top of your bash scripts -- execution will stop on errors (non-zero retvals) and on undefined variables.
http://mywiki.wooledge.org/BashFAQ/105
disagrees and refers to GreyCat's preference not to use -e at the bottom of the list of 'complications'.