PowerShell / PowerShell/PowerShell

Seemingly-obscure `${<file path>}` feature broken on Linux

Open
#25,760 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Needs-Triage WG-Engine WG-NeedsReview
Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 2h
Merged PRs (30d)
88

Description

Prerequisites

(I must note that searching the Issues page for "${" is either not possible or very difficult since there are no results, sorry if this happens to be a dupe!)

While reading the PowerShell Wikipedia page, I cane across a sentence that described a feature I have never seen documented:

Enclosing the path to a file in braces preceded by a dollar sign (as in ${C:\foo.txt}) creates a reference to the contents of the file. If it is used as an L-value, anything assigned to it will be written to the file. When used as an R-value, the contents of the file will be read. If an object is assigned, it is serialized before being stored.[citation needed]

This works on both Windows PowerShell and Core, but not on Core for Linux.

Steps to reproduce

On a Linux system, write

${/etc/profile} # (or any other file that exists)
Expected behavior
PS> ${/etc/profile}
< contents of /etc/profile here... >
Actual behavior
PS> ${/etc/profile}
< no output >
Error details
n/a
Environment data
Name                           Value
----                           -----
PSVersion                      7.5.1
PSEdition                      Core
GitCommitId                    7.5.1
OS                             Debian GNU/Linux 12 (bookworm)
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue on Linux with ${/etc/profile} and compare the result with Windows PowerShell and PowerShell Core. Trace the handling of this file-reference syntax and verify the fix by confirming that an existing file's contents are printed on Linux without regressing the documented Windows behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.