Puppet Function: sudo::safe_wildcard_cmd

Defined in:
modules/sudo/functions/safe_wildcard_cmd.pp
Function type:
Puppet Language

Overview

sudo::safe_wildcard_cmd(Stdlib::Unixpath $cmd, Stdlib::Unixpath $wildpath)Any

Parameters:

  • $cmd

    the sudo command to run

  • $wildpath

    a unixpath containing a wildcard to expand

  • cmd (Stdlib::Unixpath)
  • wildpath (Stdlib::Unixpath)

Returns:

  • (Any)

    an sudo safe command spec of the form “$cmd $wildpath, !$cmd $wildpath *, !$cmd $wildpath..*



7
8
9
10
11
12
13
14
15
# File 'modules/sudo/functions/safe_wildcard_cmd.pp', line 7

function sudo::safe_wildcard_cmd(Stdlib::Unixpath $cmd, Stdlib::Unixpath $wildpath) {
    if $wildpath !~ /\*$/ {
        "${cmd} ${wildpath}"
    } else {
        [' *', '..*'].reduce("${cmd} ${wildpath}") |$memo, $value| {
            "${memo}, !${cmd} ${wildpath}${value}"
        }
    }
}