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
Quote paths in makeWrapper #23511
Quote paths in makeWrapper #23511
Conversation
@abbradar, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @Profpatsch and @vcunat to be potential reviewers. |
local original=$1 | ||
local wrapper=$2 | ||
local original="$1" | ||
local wrapper="$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.
FYI, someone pointed out to me once that these quotes:
local original="$1"
are unneeded. But I tend to add them anyway :-)
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 suspected so because it was unquoted in most places here, but:
[abbradar@abbradarbook:~]$ test() { local a=a b c; echo $a; }
[abbradar@abbradarbook:~]$ test
a
[abbradar@abbradarbook:~]$ test() { local a="a b c"; echo $a; }
[abbradar@abbradarbook:~]$ test
a b c
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.
Eeeeeh, but:
[abbradar@abbradarbook:~]$ test() { local a=$1; echo $a; }
[abbradar@abbradarbook:~]$ test "a b c"
a b c
Bash is full of wonders...
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.
Bash is full of wonders...
Indeed :-)
Thank you |
Would it be possible to add some tests for cases that failed before and are now fixed? |
mv $prog $hidden | ||
makeWrapper $hidden $prog --argv0 '"$0"' "$@" | ||
mv "$prog" "$hidden" | ||
makeWrapper "$hidden" "$prog" --argv0 '$0' "$@" |
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.
Why remove the ""
around $0
here? Doesn’t that change the expansion in some cases?
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.
$argv0
is already quoted now; see the line above (which you've also commented).
n=$((n + 1)) | ||
fi | ||
done | ||
|
||
# Note: extraFlagsArray is an array containing additional flags | ||
# that may be set by --run actions. | ||
echo exec ${argv0:+-a $argv0} "$original" \ | ||
$flagsBefore '"${extraFlagsArray[@]}"' '"$@"' >> $wrapper | ||
echo exec ${argv0:+-a \"$argv0\"} \"$original\" \ |
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.
Maybe also add tests for non-trivial lines like these.
I'm not sure where nixpkgs tests are supposed to go but we definitely want to run tests for this, with as evil paths as possible :3 |
Sadly nowhere yet, but I might have something in the pipeline about that. ;) |
you don't need evil test cases, use Can you run |
Fixes NixOS#22962 (comment) Also run ShellCheck.
ce9306c
to
47af8ce
Compare
@grahamc I feel ashamed always forgetting about this wonderful tool. Helped fix some more problems, thanks! |
Fixes #22962 (comment) Also run ShellCheck. (cherry picked from commit 7ff6eec) For ZHF #23253 to fix e.g. blink.
The commit broke firewall test and consequently blocks nixos-unstable*. I've got no idea why ATM (bisected). They fail with:
|
There is some broken code in
EDIT: no, this works (I can swear |
Ugh, so:
results in an empty argument list. My best guess is that becase I made a workaround at abbradar@4b36413 which fixes this problem but haven't yet pushed it -- maybe some Bash guru knows how to do this more elegantly? (I argue that elegance is a relative concept so it can be applied even to Bash) |
Oh, wait, I was just tricked by Bash again. |
So the correct way to do what I wanted to is |
This broke |
Motivation for this change
Fixes #22962 (comment)
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)With this
blink
builds correctly. cc @rnhmjoj