| 143 | There are 2 solutions. The first uses !PowerShell splatting, available as of !PowerShell V2, but not easily found unless you use the term **`splatting`** in your search. The second involves manual expansion, which I prefer even though it involves more changes. The second method can also be used on the command line when piping the output of native programs. Program output raw strings rather than string arrays, since they don't care about the shell they're being invoked from. |
| 144 | |
| 145 | ==== Solution 1: Using Splatting ==== |
| 146 | Simply invoke the callees by prefixing the args array with an @ sign rather than the $ sign, like this (see comment marked as `CHANGE:`): |
| 147 | |
| 148 | **`push0.ps1`** |
| 149 | {{{#!powershell |
| 150 | # $args is the array of input arguments to any script |
| 151 | # Do some work here common to all projects |
| 152 | # like pushing code to the master repo for developer scripts, etc. |
| 153 | |
| 154 | # invoke project specific scripts here |
| 155 | # $Env:Project will be set to quake, doom or wolf |
| 156 | # call project specific push0 script if it exists |
| 157 | # and pass all arguments to it |
| 158 | $scriptName = $Env:Project + ".push0.ps1" |
| 159 | if (Test-Path $scriptName) { |
| 160 | & $scriptName @args # CHANGE: use @args instead of $args |
| 161 | } |
| 162 | }}} |
| 163 | |
| 164 | **`quake.push0.ps1`** - no change |
| 165 | |
| 166 | **`doom.push0.ps1`** - no change |
| 167 | |
| 168 | **`wolf.push0.ps1`** - no change |
| 169 | |
| 170 | |
| 171 | ==== Solution 2: Manual Expansion ==== |