Skip to content

Unix-like platforms, Windows with the experimental PSNativeWindowsTildeExpansion feature: Native tilde expansion unexpectedly expands tilde in variable references #21323

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

See also:

The expansion of an unquoted, literal, standalone ~ or of an unquoted, literal, ~/ prefix to the value of $HOME / "$HOME/" when calling native (external) programs is meant to emulate the tilde shell expansion feature in POSIX-compatible shells such as Bash.

In such shells tilde expansion is NOT performed when a path argument is provided via a variable.

PowerShell should exhibit the same behavior, but currently performs expansion nonetheless (unless the variable reference itself happens to be "..."-enclosed):

# Bash behavior, for contrast:
# ~ is NOT expanded.
bash -c 'p="~"; echo $p'

# !! PowerShell DOES expand
$p = '~'
/bin/echo $p

Expected behavior

~
~

Actual behavior

~
/home/jdoe

Error details

No response

Environment data

PowerShell 7.5.0-preview.2

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.WG-Languageparser, language semanticsWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions