You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Native tilde expansion is inappropriately applied indirectly, to arguments supplied via unquoted variable references #27192
Needs-TriageThe issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working Group
Native tilde when calling external (native) programs is inappropriately also applied to indirectly passed unquoted arguments, via variable values.
This is not how tilde expansion works in POSIX-compatible shells, which PowerShell is meant to emulate.
Note: By contrast, with respect to pathname expansion (globbing), an indirectly passed argument should and does still expand, as long as the variable reference is passed unquoted (e.g. printf $var). This discrepancy is owed to the order in which POSIX-compatible shells perform shell expansions.
While the workaround is to quote a reference to a variable whose value starts with ~ (e.g. printf "$var"), this shouldn't be necessary.
# On Unix; applies analogously to Windows in v7.6.0+# Show Bash' behavior.
bash -c "arg1='~'; printf '%s\n' `$arg1"# Putatively equivalent PowerShell behavior.$arg1='~'; printf '%s\n'$arg1
Expected behavior
~~
That is, the argument should be passed verbatim in both cases.
Actual behavior
~/home/jdoe
That is, PowerShell still expanded ~, even though it was provided via a variable value.
Yes, the by-design advent of tilde expansion in Windows in 7.6.0 undoubtedly technically constitutes a breaking change.
The presumption must have been that this is acceptable, due to being unlikely to affect real-world scripts, i.e. that the breaking change falls into bucket 3.
If someone feels strongly enough that the change doesn't fall into bucket 3, it may be worth creating a meta-issue that compiles additional real-world example - assuming they exist.
By contrast, the issue at hand was submitted under the assumption that the new feature is here to stay.
I just realized that this came up before, before the formerly PSNativeWindowsTildeExpansion experimental feature became a stable one; the linked issue provides additional background:
Needs-TriageThe issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working Group
Activity
mklement0 commentedon Apr 6, 2026
Yes, the by-design advent of tilde expansion in Windows in 7.6.0 undoubtedly technically constitutes a breaking change.
The presumption must have been that this is acceptable, due to being unlikely to affect real-world scripts, i.e. that the breaking change falls into bucket 3.
wsl ~works in 7.5 but fails in 7.6 due to tilde expansion and argument mangling #27098By contrast, the issue at hand was submitted under the assumption that the new feature is here to stay.
mklement0 commentedon Oct 10, 2026
I just realized that this came up before, before the formerly
PSNativeWindowsTildeExpansionexperimental feature became a stable one; the linked issue provides additional background:PSNativeWindowsTildeExpansionfeature: Native tilde expansion unexpectedly expands tilde in variable references #21323