-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
lib.cli.escapeShellArg{,s}: Only escape when necessary #333744
lib.cli.escapeShellArg{,s}: Only escape when necessary #333744
Conversation
These utilities are like `escapeShellArg{,s}` except that they will leave the string undisturbed if it doesn't need to be quoted (because it doesn't have any special characters). This can help generate nicer-looking command lines.
Oh this is nice! I don't think we need a separate function for this actually. While the existing ones have
And even if we assume |
Also a minor nit for the commit message: This function is not in |
I'll get to your feedback soon. Also, just to clarify: are you saying it's okay to make this the new behavior of |
Yes I think that would be okay :) |
This would need to target |
escapeBashArg{,s}
Alright, I think this is ready for re-review (and rebased against |
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.
LGTM. Disadvantaging non‐ASCII alphabetical characters is unfortunate, but probably better than trying to correctly handle Unicode in a language that doesn’t really support it. This seems like it should be a big improvement for standard CLI cases. Hard to say if there’ll be any Hyrum’s law type breakage, but I think it’s worth a try at least.
I’ll let @infinisil do another round of reviews, but could you squash the commits together before merge? Right now this PR would break git bisect
.
@emilazy: I typically squash merge (and clean up the commit message in the process of doing so) |
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.
Looks good to me!
This needs to be a single‐quoted string; #333744 broke this incorrect use. Hyrum’s law strikes again!
This also caused a regression in the dokuwiki module. |
|
Fixes tests that are affected by NixOS/nixpkgs#333744.
Fixes tests that are affected by <NixOS/nixpkgs#333744>.
Fixes tests that are affected by <NixOS/nixpkgs#333744>.
Fixes tests that are affected by <NixOS/nixpkgs#333744>.
Fixes tests that are affected by <NixOS/nixpkgs#333744>.
Another Hyrum’s law issue: LnL7/nix-darwin#1068. (I don’t think it was necessarily wrong to do the PR this way or anything; just feel it is interesting/useful have a reference for the kinds of ways semantics‐preserving changes like this can result in downstream users breaking.) |
PHP strings don't obey shell quoting rules. See #333744.
Yeah, this is why my original change didn't make this behavior the default. |
Fixes tests that are affected by <NixOS/nixpkgs#333744>.
Fixes tests that are affected by <NixOS/nixpkgs#333744>.
Fixes tests that are affected by <NixOS/nixpkgs#333744>.
Changes to escapeShellArg introduced in NixOS/nixpkgs#333744 made different versions of nixpkgs behave differently. If current nix-darwin is used with nixpkgs before that change, labels end up having labels quoted twice (see LnL7#1085), but without changes from LnL7#1055, with new nixpkgs, labels end up not quoted at all, and ShellCheck ends up complaining that commas might have been used as array item separator (see https://www.shellcheck.net/wiki/SC2054). Use the old version of escapeShellArg to always escape the list of labels and make nix-darwin work with both old and new versions of nixpkgs. Fixes LnL7#1085
Changes to escapeShellArg introduced in NixOS/nixpkgs#333744 made different versions of nixpkgs behave differently. If current nix-darwin is used with nixpkgs before that change, labels end up having labels quoted twice (see LnL7#1085), but without changes from LnL7#1055, with new nixpkgs, labels end up not quoted at all, and ShellCheck ends up complaining that commas might have been used as array item separator (see https://www.shellcheck.net/wiki/SC2054). Use the old version of escapeShellArg to always escape the list of labels and make nix-darwin work with both old and new versions of nixpkgs. Fixes LnL7#1085
Changes to escapeShellArg introduced in NixOS/nixpkgs#333744 made different versions of nixpkgs behave differently. If current nix-darwin is used with nixpkgs before that change, labels end up having labels quoted twice (see LnL7#1085), but without changes from LnL7#1055, with new nixpkgs, labels end up not quoted at all, and ShellCheck ends up complaining that commas might have been used as array item separator (see https://www.shellcheck.net/wiki/SC2054). Use the old version of escapeShellArg to always escape the list of labels and make nix-darwin work with both old and new versions of nixpkgs. Fixes LnL7#1085
Regression introduced in 94bc0f5, because I developed against unstable, which has NixOS/nixpkgs#333744 merged, while 24.05 doesn't. Partly shellchecks mistake, see koalaman/shellcheck#2891 but whatever, we can't do much more about it than ignore the warning. Fixes #868
Regression introduced in 94bc0f5, because I developed against unstable, which has NixOS/nixpkgs#333744 merged, while 24.05 doesn't. Partly shellchecks mistake, see koalaman/shellcheck#2891 but whatever, we can't do much more about it than ignore the warning. Fixes #868
Fixes tests that are affected by <NixOS/nixpkgs#333744>.
Yup: #367288 |
Sorry for not pushing back harder on repurposing the name here. I think it’s pointless to revert at this point now that it’s in a stable release though (but it’s a useful lesson for next time). |
Fixes tests that are affected by <NixOS/nixpkgs#333744>.
These utilities will now leave the string undisturbed if it doesn't need to be quoted (because it doesn't have any special characters). This can help generate nicer-looking command lines.
Description of changes
Things done
Add a 👍 reaction to pull requests you find important.