From 079035fe56820ee9dc70e34abbdc8278bfb2d28e Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 11 Nov 2023 17:21:05 -0700 Subject: [PATCH] doc(pwsh-essentials): add section on command arguments --- pwsh-essentials/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pwsh-essentials/README.md b/pwsh-essentials/README.md index 4cb8905..3fcfe52 100644 --- a/pwsh-essentials/README.md +++ b/pwsh-essentials/README.md @@ -173,6 +173,22 @@ pwsh -ExecutionPolicy Bypass $HOME\.local\bin\_webi.ps1 xz & ".\Foo Bar\foobar.exe" -baz ``` +To use it with multiple arguments: + +```pwsh +# this can be just the name, or the full path +$Cmd = 'curl.exe' + +# mind the leading , +$CmdArguments = , '--fail-with-body', '-sS' + +& $Cmd $CmdArguments -o example.html 'https://example.com' +``` + +As you can see, the array of options and arguments is flattened, which makes +constructing commands with complex arrangements much easier than... +posix (but don't tell my friends I said that). + ### 4. PowerShell's curl vs Windows' curl.exe PowerShell has a built-in `curl` which is an alias for the `Invoke-WebRequest`