Title: Native tilde expansion is inappropriately applied indirectly, to arguments supplied via unquoted variable references · Issue #27192 · PowerShell/PowerShell · GitHub
Open Graph Title: Native tilde expansion is inappropriately applied indirectly, to arguments supplied via unquoted variable references · Issue #27192 · PowerShell/PowerShell
X Title: Native tilde expansion is inappropriately applied indirectly, to arguments supplied via unquoted variable references · Issue #27192 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/27192
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Native tilde expansion is inappropriately applied indirectly, to arguments supplied via unquoted variable references","articleBody":"### Prerequisites\n\n- [x] Write a descriptive title.\n- [x] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [x] Search the existing issues.\n- [x] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [x] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\nNative tilde when calling external (native) programs is inappropriately also applied to _indirectly_ passed unquoted arguments, via _variable values_.\n\nThis is not how tilde expansion works in POSIX-compatible shells, which PowerShell is meant to emulate.\n\nNote: 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](https://www.gnu.org/software/bash/manual/html_node/Shell-Expansions.html).\n\nWhile the workaround is to _quote_ a reference to a variable whose value starts with `~` (e.g. `printf \"$var\"`), this shouldn't be necessary.\n\n```powershell\n# On Unix; applies analogously to Windows in v7.6.0+\n# Show Bash' behavior.\nbash -c \"arg1='~'; printf '%s\\n' `$arg1\"\n# Putatively equivalent PowerShell behavior.\n$arg1 = '~'; printf '%s\\n' $arg1\n```\n\n### Expected behavior\n\n```console\n~\n~\n```\n\nThat is, the argument should be passed _verbatim_ in both cases.\n\n### Actual behavior\n\n```console\n~\n/home/jdoe\n```\n\nThat is, PowerShell still expanded `~`, even though it was provided via a variable value.\n\n### Error details\n\n```console\n\n```\n\n### Environment data\n\n```powershell\nPowerShell 7.6.0\n```\n\n### Visuals\n\n_No response_","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2026-04-05T21:13:04Z","url":"https://github.com/PowerShell/PowerShell/issues/27192"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b3802494-3e0d-c0ce-25d7-4c10a4a50f73 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E448:2ACF16:1B7125:25A47A:6AFD4FFC |
| html-safe-nonce | 23e01a885e26beeeabbd021f8a6183834c8d1a6c516975742919891b109209f1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDQ4OjJBQ0YxNjoxQjcxMjU6MjVBNDdBOjZBRkQ0RkZDIiwidmlzaXRvcl9pZCI6IjQyNzY0NDQwNTczMzAwNzc2OTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1a8c99205159c5a61e7cb30fcde473d9b3e30b07d23bb3e2f0fe649359e80d3d |
| hovercard-subject-tag | issue:4208589614 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/27192/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b8f942baeb4de21a3062f7d7014090504a08e56dc857e0e3c4f8a72768aef63a/PowerShell/PowerShell/issues/27192 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b8f942baeb4de21a3062f7d7014090504a08e56dc857e0e3c4f8a72768aef63a/PowerShell/PowerShell/issues/27192 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width