Skip to content

Commit b999f28

Browse files
committed
npm/global_config_entry.pp: improve shell quoting
For safety and readability.
1 parent f558f49 commit b999f28

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

manifests/npm/global_config_entry.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
if $config_setting =~ /(_|:_)/ {
1818
$onlyif_command = $facts['os']['family'] ? {
1919
'Windows' => "${cmd_exe_path} /C FOR /F %G IN ('${npm_path} config get globalconfig') DO IF EXIST %G (FINDSTR /B /C:\"${$config_setting}\" %G) ELSE (EXIT 1)",
20-
default => "test -f $(${npm_path} config get globalconfig) && grep -qe \"^${$config_setting}\" $(${npm_path} config get globalconfig)",
20+
default => "test -f \"$(${npm_path} config get globalconfig)\" && grep -qe '^${$config_setting}' \"$(${npm_path} config get globalconfig)\"",
2121
}
2222
}
2323
else {
2424
$onlyif_command = $facts['os']['family'] ? {
2525
'Windows' => "${cmd_exe_path} /C ${npm_path} get --global| FINDSTR /B \"${config_setting}\"",
26-
default => "${npm_path} get --global | grep -e \"^${config_setting}\"",
26+
default => "${npm_path} get --global | grep -e '^${config_setting}'",
2727
}
2828
}
2929
}
@@ -35,13 +35,13 @@
3535
if $config_setting =~ /(_|:_)/ {
3636
$onlyif_command = $facts['os']['family'] ? {
3737
'Windows' => "${cmd_exe_path} /V /C FOR /F %G IN ('${npm_path} config get globalconfig') DO IF EXIST %G (FINDSTR /B /C:\"${$config_setting}=\\\"${$value}\\\"\" %G & IF !ERRORLEVEL! EQU 0 ( EXIT 1 ) ELSE ( EXIT 0 )) ELSE ( EXIT 0 )",
38-
default => "! test -f $(${npm_path} config get globalconfig) || ! grep -qe '^${$config_setting}=\"\\?${$value}\"\\?$' $(${npm_path} config get globalconfig)",
38+
default => "! test -f \"$(${npm_path} config get globalconfig)\" || ! grep -qe '^${$config_setting}=\"\\?${$value}\"\\?$' \"$(${npm_path} config get globalconfig)\"",
3939
}
4040
}
4141
else {
4242
$onlyif_command = $facts['os']['family'] ? {
4343
'Windows' => "${cmd_exe_path} /C FOR /F %i IN ('${npm_path} get ${config_setting} --global') DO IF \"%i\" NEQ \"${value}\" ( EXIT 0 ) ELSE ( EXIT 1 )",
44-
default => "test \"$(${npm_path} get ${config_setting} --global | tr -d '\n')\" != \"${value}\"",
44+
default => "test \"$(${npm_path} get ${config_setting} --global | tr -d '\n')\" != '${value}'",
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)