stdenv: use command that doesn't exit non-zero#130592
stdenv: use command that doesn't exit non-zero#130592happysalada wants to merge 1 commit intoNixOS:stagingfrom
Conversation
06e2093 to
090b162
Compare
|
I'm not sure what the failure is on the tests. Maybe it's just a transient thing. |
|
The failures appears to be |
| local hookName="$2" | ||
| if declare -F "$hookName" > /dev/null; then | ||
| "$hookName" | ||
| elif type -p "$hookName" > /dev/null; then |
There was a problem hiding this comment.
This is not semantically equivalent.
type -plooks up the PATH for a program called "$hookName". If it exists, it outputs its location and exits with 0. Otherwise it exits with 1.test -echecks if a file located at "$hookName" exists. If it does, it exits with 0. Otherwise it exits with 1.
There was a problem hiding this comment.
There is a case where both would yield the same result, if $hookName points to a relative and executable path.
There was a problem hiding this comment.
Thank you for the feeback!
I think you're right here and that change is a mistake.
I'm going to do one more test, but it seems weird to me that the original code is generating an error. From what I understood, in bash, if a command is in an if statement then the errexit should be ignored.
Perhaps the strict_all flag of osh is removing that behavior.
I'll test again and will ask andrew if that is the case.
|
I marked this as stale due to inactivity. → More info |
Motivation for this change
This is a PR in the series of stdenv shell improvements.
This current PR replaces a command that exits with a non-zero code on failure with one that does not.
The code is in my opinion a test semantic rather than an "exit on failure" one.
This change serves in enabling strict err exit at some point.
In the previous commit @zimbatm pointed that the semantics are a little different.
If the $hookName is a directory the semantics change. In my experience this cannot be possible, however this is something that will need to be verified with the hydra tests.
Things done
sandboxinnix.confon non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)