linkFarm: allow files/directories with leading dashes
Calling linkFarm with leading dashes, makes the used coreutils commands misidentify a filename, like "-foo", as a list of options, instead of an positional argument.
This commit is contained in:
parent
18d794dd01
commit
b1a3c47018
@ -671,8 +671,8 @@ rec {
|
||||
throw "linkFarm entries must be either attrs or a list!";
|
||||
|
||||
linkCommands = lib.mapAttrsToList (name: path: ''
|
||||
mkdir -p "$(dirname ${lib.escapeShellArg "${name}"})"
|
||||
ln -s ${lib.escapeShellArg "${path}"} ${lib.escapeShellArg "${name}"}
|
||||
mkdir -p -- "$(dirname -- ${lib.escapeShellArg "${name}"})"
|
||||
ln -s -- ${lib.escapeShellArg "${path}"} ${lib.escapeShellArg "${name}"}
|
||||
'') entries';
|
||||
in
|
||||
runCommand name
|
||||
|
@ -39,6 +39,11 @@ let
|
||||
linkFarmFromAttrs = linkFarm "linkFarmFromAttrs" {
|
||||
inherit foo hello;
|
||||
};
|
||||
|
||||
linkFarmDelimitOptionList = linkFarm "linkFarmDelimitOptionList" {
|
||||
"-foo" = foo;
|
||||
"-hello" = hello;
|
||||
};
|
||||
in
|
||||
runCommand "test-linkFarm" { } ''
|
||||
function assertPathEquals() {
|
||||
@ -61,5 +66,9 @@ runCommand "test-linkFarm" { } ''
|
||||
|
||||
assertPathEquals "${linkFarmFromAttrs}/foo" "${foo}"
|
||||
assertPathEquals "${linkFarmFromAttrs}/hello" "${hello}"
|
||||
|
||||
assertPathEquals "${linkFarmDelimitOptionList}/-foo" "${foo}"
|
||||
assertPathEquals "${linkFarmDelimitOptionList}/-hello" "${hello}"
|
||||
|
||||
touch $out
|
||||
''
|
||||
|
Loading…
x
Reference in New Issue
Block a user