Skip to content
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

wrapFish: fix singleton expansion in shell init #113232

Merged

Conversation

pacien
Copy link
Contributor

@pacien pacien commented Feb 15, 2021

This fixes the expansion of the configuration path in the pathological
case of a singleton, which would otherwise be used verbatim with the
surrounding braces for lookup.

GitHub: see #108491 (review)

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

This fixes the expansion of the configuration path in the pathological
case of a singleton, which would otherwise be used verbatim with the
surrounding braces for lookup.

GitHub: see NixOS#108491 (review)
@pacien
Copy link
Contributor Author

pacien commented Feb 15, 2021

CC @teehemkay

@r-rmcgibbo
Copy link

Result of nixpkgs-review pr 113232 at 9c62b91 run on x86_64-linux 1

2 packages built:


in writeShellScriptBin "fish" ''
${fish}/bin/fish --init-command "
set --prepend fish_complete_path ${escapeShellArgs complPath}
set --prepend fish_function_path ${escapeShellArgs funcPath}
for c in {${concatStringsSep "," safeConfPath}}/*; source $c; end
set --local fish_conf_source_path ${escapeShellArgs confPath}
for c in $fish_conf_source_path/*; source $c; end
Copy link

@teehemkay teehemkay Feb 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pacien I may be missing something obvious, but isn't this going to break in the case where confPath is not a singleton?

Copy link

@teehemkay teehemkay Feb 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ignore my previous comment and thank you for helping me better understand fish cartesian products.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same question and had to run it myself to totally understand:

$ mkdir a b c d e
$ touch a/1 b/2 c/3 d/4 e/5
$ set --local test a b c d e
$ for c in $test/*; echo $c; end
a/1
b/2
c/3
d/4
e/5

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff LGTM, thanks!

@cole-h cole-h merged commit c6efc0b into NixOS:master Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants