mirror of
https://github.com/nix-community/home-manager
synced 2025-01-11 19:49:49 +01:00
files: properly escape shell arguments
This commit is contained in:
parent
4ed6705b0f
commit
c982c19f53
1 changed files with 7 additions and 7 deletions
|
@ -53,7 +53,7 @@ in
|
||||||
# Paths that should be forcibly overwritten by Home Manager.
|
# Paths that should be forcibly overwritten by Home Manager.
|
||||||
# Caveat emptor!
|
# Caveat emptor!
|
||||||
forcedPaths =
|
forcedPaths =
|
||||||
concatMapStringsSep " " (p: ''"$HOME/${p}"'')
|
concatMapStringsSep " " (p: ''"$HOME"/${escapeShellArg p}'')
|
||||||
(mapAttrsToList (n: v: v.target)
|
(mapAttrsToList (n: v: v.target)
|
||||||
(filterAttrs (n: v: v.force) cfg));
|
(filterAttrs (n: v: v.force) cfg));
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ in
|
||||||
|
|
||||||
# A symbolic link whose target path matches this pattern will be
|
# A symbolic link whose target path matches this pattern will be
|
||||||
# considered part of a Home Manager generation.
|
# considered part of a Home Manager generation.
|
||||||
homeFilePattern="$(readlink -e "${builtins.storeDir}")/*-home-manager-files/*"
|
homeFilePattern="$(readlink -e ${escapeShellArg builtins.storeDir})/*-home-manager-files/*"
|
||||||
|
|
||||||
forcedPaths=(${forcedPaths})
|
forcedPaths=(${forcedPaths})
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ in
|
||||||
|
|
||||||
# A symbolic link whose target path matches this pattern will be
|
# A symbolic link whose target path matches this pattern will be
|
||||||
# considered part of a Home Manager generation.
|
# considered part of a Home Manager generation.
|
||||||
homeFilePattern="$(readlink -e "${builtins.storeDir}")/*-home-manager-files/*"
|
homeFilePattern="$(readlink -e ${escapeShellArg builtins.storeDir})/*-home-manager-files/*"
|
||||||
|
|
||||||
newGenFiles="$1"
|
newGenFiles="$1"
|
||||||
shift 1
|
shift 1
|
||||||
|
@ -245,9 +245,9 @@ in
|
||||||
}
|
}
|
||||||
declare -A changedFiles
|
declare -A changedFiles
|
||||||
'' + concatMapStrings (v: ''
|
'' + concatMapStrings (v: ''
|
||||||
_cmp "${sourceStorePath v}" "${homeDirectory}/${v.target}" \
|
_cmp ${escapeShellArg (sourceStorePath v)} ${escapeShellArg homeDirectory}/${escapeShellArg v.target} \
|
||||||
&& changedFiles["${v.target}"]=0 \
|
&& changedFiles[${escapeShellArg v.target}]=0 \
|
||||||
|| changedFiles["${v.target}"]=1
|
|| changedFiles[${escapeShellArg v.target}]=1
|
||||||
'') (filter (v: v.onChange != "") (attrValues cfg))
|
'') (filter (v: v.onChange != "") (attrValues cfg))
|
||||||
+ ''
|
+ ''
|
||||||
unset -f _cmp
|
unset -f _cmp
|
||||||
|
@ -256,7 +256,7 @@ in
|
||||||
|
|
||||||
home.activation.onFilesChange = hm.dag.entryAfter ["linkGeneration"] (
|
home.activation.onFilesChange = hm.dag.entryAfter ["linkGeneration"] (
|
||||||
concatMapStrings (v: ''
|
concatMapStrings (v: ''
|
||||||
if [[ ${"$\{changedFiles"}["${v.target}"]} -eq 1 ]]; then
|
if [[ ''${changedFiles[${escapeShellArg v.target}]} -eq 1 ]]; then
|
||||||
${v.onChange}
|
${v.onChange}
|
||||||
fi
|
fi
|
||||||
'') (filter (v: v.onChange != "") (attrValues cfg))
|
'') (filter (v: v.onChange != "") (attrValues cfg))
|
||||||
|
|
Loading…
Reference in a new issue