From ff1253813c7b8f1b1489bdcbe71c7a40e39fb81d Mon Sep 17 00:00:00 2001 From: kovan Date: Sat, 14 Mar 2026 20:18:14 +0100 Subject: [PATCH] Update CLI quoting section for PowerShell 7.3 changes PowerShell 7.3 changed how arguments with embedded quotes are passed to external programs via the PSNativeCommandArgumentPassing preference. The triple-quote (""") workaround from the old docs relied on legacy behavior that no longer applies in pwsh 7.3+. Update the examples to use backslash-escaped double quotes inside single quotes, which works across both Windows PowerShell 5.1 and PowerShell 7.3+. Add a note explaining the version difference. Fixes #678 --- content/reference/clojure_cli.adoc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/content/reference/clojure_cli.adoc b/content/reference/clojure_cli.adoc index 8ab877c8..ac4f896d 100644 --- a/content/reference/clojure_cli.adoc +++ b/content/reference/clojure_cli.adoc @@ -571,21 +571,23 @@ These data types need to be surrounded by single quotes: * Sets - `'#{:a :b}'` * Lists - `'(1 2 3)'` -On Windows, WSL2 shells can follow the advice above, but using clojure.exe, additional escape quoting is required for string values. Unfortunately the combination of quoting rules for converting command line Windows program arguments, quoting, and word splitting are https://stackoverflow.com/a/59681993/7671[very complicated]. +On Windows, WSL2 shells can follow the advice above, but using clojure.exe, additional escape quoting is required for string values. Unfortunately the combination of quoting rules for converting command line Windows program arguments, quoting, and word splitting are https://stackoverflow.com/a/59681993/7671[very complicated]. -To pass a string value at the top level, if the string value does not have spaces, you can use `'\"str\"'`. If the string value does have spaces (or not) you should use `'"""str value"""'`. +NOTE: PowerShell 7.3 changed how arguments with embedded quotes are passed to external programs (via the `$PSNativeCommandArgumentPassing` preference variable, which defaults to `'Windows'` in 7.3+). The examples below work with Windows PowerShell 5.1 and PowerShell 7.3+. If you are using PowerShell 7.0-7.2, you may need to adjust quoting or set `$PSNativeCommandArgumentPassing = 'Legacy'`. + +To pass a string value at the top level, use backslash-escaped double quotes inside single quotes: [source] ---- -PS D:> clj -X clojure.core/prn :string1 '\"no-spaces\"' :string2 '"""has spaces"""' +PS D:> clj -X clojure.core/prn :string1 '\"no-spaces\"' :string2 '\"has spaces\"' {:string1 "no-spaces", :string2 "has spaces"} ---- -For string values nested inside other collections, use double quotes if there are spaces and triple quotes if there are not: +For string values nested inside other collections, use backslash-escaped double quotes: [source] ---- -PS D:> clj -X clojure.core/prn :val '{:s1 """nospaces""" :s2 ""has spaces""}' +PS D:> clj -X clojure.core/prn :val '{:s1 \"nospaces\" :s2 \"has spaces\"}' {:val {:s1 "nospaces", :s2 "has spaces"}} ----