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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdenv: force unaliased rm
in default fixup (avoids prompt)
#290775
base: staging
Are you sure you want to change the base?
Conversation
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/3694 |
@@ -87,7 +87,7 @@ stripDirs() { | |||
# be stripped, so ignore specifically this code. | |||
[[ "$exit_code" = 123 || -z "$exit_code" ]] || (cat "$striperr" 1>&2 && exit 1) | |||
|
|||
rm "$striperr" | |||
rm -f "$striperr" |
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.
-f also hides errors. I think a proper solution would be to unalias common aliases.
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.
This would also solve the problem with mv
and cp
not letting a -f
override a -i
馃憤 But it'd have to be local to the function, because we can't suddenly turn off a alias rm='rm -i'
in someone's dev shell
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 think we should rather remove all aliases in the beginning of genericBuild otherwise we could need to add \
to potentially many program executions and the cost of rebuilding stdenv everytime.
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 tried to design a POC but it turns out to be surprisingly difficult to do this for a function sourced by an interactive shell.
test.sh:
foo () {
echo foo
}
foo_subshell () (
echo foo
)
foo_unalias () {
unalias -a
echo foo
}
foo_unalias_subshell () (
unalias -a
echo foo
)
foo_shopt () {
shopt -u expand_aliases
echo foo
shopt -s expand_aliases
}
foo_shopt_subshell () (
shopt -u expand_aliases
echo foo
shopt -s expand_aliases
)
Result:
$ alias echo="echo aliased"
$ source test.sh
$ foo
aliased foo
$ foo_subshell
aliased foo
$ foo_unalias
aliased foo
$ foo_unalias_subshell
aliased foo
$ foo_shopt
aliased foo
$ foo_shopt_subshell
aliased foo
$ echo hello
hello
Do you have any other ideas?
(Edit: I agree with your point btw, I just can't think of a nice way to do it :/ )
f296441
to
6d0586a
Compare
When running `genericBuild` interactively from a nix-shell, a bare `rm` without could be aliased to `rm -i`, which would cause a prompt to the user. This is a pretty common alias. Same would hold for cp, mv, etc.
6d0586a
to
c101440
Compare
rm
in default fixup (avoids prompt)
Description of changes
When running
genericBuild
interactively from a nix-shell, a barerm
without -f will cause a prompt to the user if they have rm aliased torm -i
. This is a pretty common alias.Same would hold for cp, mv, etc.
Obviously a pretty painful patch in terms of rebuilds... :/
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 馃憤 reaction to pull requests you find important.