-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
stdenv-setup: fix substituteAll with set -eu #28799
Conversation
@orivej, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Ericson2314, @vcunat and @domenkozar to be potential reviewers. |
d0704a8
to
bd51c02
Compare
Ugh, overriding a builtin feels dirty. Does |
This is what 9e0d042 and [1] above tried to do, but |
How about I checked gawk is in Darwin bootstrap tools and |
Good idea! |
|
@copumpkin |
Actually, overriding builtins with functions is well defined:
https://www.gnu.org/software/bash/manual/html_node/Command-Search-and-Execution.html Nevertheless, I'm going to continue with Could someone test this on hydra? I have successfully built some packages on Linux and Darwin with this pull request, but I don't know how to test properly without hydra. |
@orivej are you sure that's still true? I thought that was only true because |
@copumpkin You are right, since 2bc7b4e Darwin always uses Bash from nixpkgs for |
err in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With or without awk
seems fine to me. Thanks for fixing!
@@ -497,10 +497,8 @@ substitute() { | |||
shift 2 | |||
# check if the used nix attribute name is a valid bash name | |||
if ! [[ "$varName" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then | |||
echo "${FUNCNAME[0]}(): WARNING: substitution variables should be valid bash names," >&2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just hardcode substitute():
too. That is what was there before, IIRC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with FUNCNAME
. Why did you use it 5d693c8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No great reason, just in-case the code was moved elsewhere / general principle of things not knowing their own name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to replace ${FUNCNAME[0]}
with substitute
, I can do this in this pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't care which, I'd just like to have something saying what the function is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'll merge it after that.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I did not get that you asked for the function name here too. Done.
pkgs/stdenv/generic/setup.sh
Outdated
echo " \"$varName\" isn't and therefore was skipped; it might be caused" >&2 | ||
echo " by multi-line phases in variables - see #14907 for details." >&2 | ||
continue | ||
echo "substitution variables must be valid Bash names, \"$varName\" isn't." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The >&2
should also still be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, didn't notice that.
f2cd568
to
16761a3
Compare
Environment variable filter in substituteAll was not precise and produced undefined and invalid variable names. Vladimír Čunát tried to fix that in [1], but `env -0` did not work during Darwin bootstrap, so [2] reverted this change and replaced an error due to invalid variables with a warning. Recently in NixOS#28057 John Ericson added `set -u` to `setup.sh` and undefined variables made the setup fail during e.g. `nix-build -A gnat` with `setup: line 519: !varName: unbound variable`. [1] NixOS@62fc885 [2] NixOS@81df035
Thanks @orivej! |
Motivation for this change
Environment variable filter in substituteAll was not precise and produced undefined and invalid variable names. Vladimír Čunát tried to fix that in [1], but
env -0
did not work during Darwin bootstrap, so [2] reverted this change and replaced an error due to invalid variables with a warning. Recently in #28057 John Ericson addedset -u
tosetup.sh
and undefined variables made the setup fail during e.g.nix-build -A gnat
withsetup: line 519: !varName: unbound variable
.This patch fixes the cause of such warnings as [3]:
[1] 62fc885
[2] 81df035
[3] #14907 (comment)
Things done
Tested building some packages (e.g.
nix
) on NixOS and Darwin.(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)