Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail on installation error #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

barak
Copy link

@barak barak commented Jan 13, 2016

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

This shell setting causes the script to fail is a command inside it fails.
So if the mkdir fails, ...
@sraue
Copy link
Contributor

sraue commented Jan 13, 2016

mkdir -p should never fail (?)

@barak
Copy link
Author

barak commented Jan 13, 2016

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
Copy link

chewitt commented Jan 14, 2016

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

@barak
Copy link
Author

barak commented Jan 15, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants