OpenELEC / iwlwifi-firmware

104 stars 62 forks source link

fail on installation error #5

Open barak opened 8 years ago

barak commented 8 years ago

This shell setting causes the script to fail if a command inside it fails. So if the mkdir fails, ...

sraue commented 8 years ago

mkdir -p should never fail (?)

barak commented 8 years ago

There are lots of reasons mkdir -p can fail.

$ mkdir -p /foo
mkdir: cannot create directory ‘/foo’: Permission denied

Not just insufficient permissions or not being root, but also things like targeting a read-only filesystem, or no space left on device, or a hardware fault, or being denied by ACL or SELinux or other security mechanisms, etc.

Basically, it is good practice to start all shell scripts with set -e unless you have a really good reason not to. If you want to ignore errors in some particular command, this can be done on an individual basis: command-where-error-is-okay || echo ignore error.

chewitt commented 8 years ago

@barak are you reviewing our installer scripts for potential/theoretical issues or reporting an actual experienced-during-install problem?

barak commented 8 years ago

It is not be appropriate to use scripts that might silently fail in an automatic build system, which is the space I'm coming from. This particular script is trivial, and so there's no compelling need to use it. I simply bypassed it in what I was doing.

Reported the issue basically on autopilot, out of symmetry, as I appreciate it when people report silent failure modes in my own code...