Live data from Hacker News

Bug 1202858 – Restarting squid results in deleting all files in hard-drive

bugzilla.redhat.com

81–90 of 179 posts

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#81
post #32

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.

Elephant in the room- shell is a bizarre language

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#82
post #32

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.

I wonder why set -eu is not the default setting.

set -u is good. set -e requires to change a lot of code. See for example

https://github.com/icy/bash-coding-style#set--e

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#83

My 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.

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

#84

My 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.

zsh is an interactive shell. It is not to replace #bash as system shell as I know.

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#85
post #69
post #14

Earlier 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.

This is simply not true. Could you provide evidence rather than making stuff up.

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#87
post #72

Earlier 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.

grep -r shouldn't follow symlinks, -R does however:

      -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 symlinks

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#88
post #41

Earlier 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...

Parent said "This is why as a user I like Apple's OS X sandbox.".

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

#89

Earlier 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.

No. If the script has the #! set as /bin/bash, then it will run as bash.

Re: Bug 1202858 – Restarting squid results in deleting all files in hard-drive

#90
post #32
post #11

Earlier 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.

That's not as simple or clear as you make it sound though.

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'.

Post reply on HN