Skip to content

Backtick-escaping doesn't work for suppressing native tilde and pathname expansions #27116

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

The promise of `-escaping is to treat whatever character follows verbatim, i.e. to suppress the usual interpretation of potential metacharacters.

While this works with true metacharacters such as $ and @, it unexpectedly doesn't work with unquoted instances of ~, and - on Unix-like platforms only - *, and ? in the context of tilde and pathname expansion for native (external) programs.

# On Unix; applies analogously on Windows (with respect to '~' only) in v7.6+
printf '~'
printf `~

Expected behavior

~
~

Actual behavior

~
/home/jdoe 

That is, `-escaping wasn't effective in suppressing the tilde expansion.
Contrast this with printf `@, which works as expected.

Error details

Environment data

PowerShell Core v7.6.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions