PowerShell / PowerShell/PowerShell
Seemingly-obscure `${<file path>}` feature broken on Linux
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
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.
(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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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