1
1
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-08-17 00:20:44 +03:00

Merge pull request #471 from tianyaochou/fix-alias-shell-escape

add escape to shell aliases
This commit is contained in:
Domen Kožar 2022-08-22 09:52:46 +02:00 committed by GitHub
commit b344a20e80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -9,7 +9,8 @@ let
mapAttrsToList (n: v: ''export ${n}="${v}"'') cfg.variables;
aliasCommands =
mapAttrsFlatten (n: v: ''alias ${n}="${v}"'') cfg.shellAliases;
mapAttrsFlatten (n: v: ''alias ${n}=${escapeShellArg v}'')
(filterAttrs (k: v: v != null) cfg.shellAliases);
makeDrvBinPath = concatMapStringsSep ":" (p: if isDerivation p then "${p}/bin" else p);
in

View File

@ -9,7 +9,8 @@ let
cfg = config.programs.fish;
fishAliases = concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias ${k} '${v}'") cfg.shellAliases
mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}")
(filterAttrs (k: v: v != null) cfg.shellAliases)
);
envShellInit = pkgs.writeText "shellInit" cfge.shellInit;

View File

@ -43,6 +43,6 @@
echo >&2 "checking zsh variables in /etc/zprofile"
grep 'FOO="42"' ${config.out}/etc/zprofile
echo >&2 "checking shell aliases in /etc/zprofile"
grep 'alias ls="ls -G"' ${config.out}/etc/zprofile
grep "alias ls='ls -G'" ${config.out}/etc/zprofile
'';
}