Skip to content

PowerShell wrapper breaks some common GNU command forms #23

Description

With the PowerShell wrapper enabled, I still hit a few GNU command lines that behave in surprising ways.

The clearest one is a filename starting with -:

Set-Content -LiteralPath '-dash.txt' -Value 'dash file foo'
cat -- -dash.txt

Expected:

dash file foo

Actual:

cat.cmd: '-dash': The system cannot find the file specified.
cat: .txt: The system cannot find the file specified.

It looks like -dash.txt is getting split into -dash and .txt. The same shape also fails for me with:

grep foo -- -dash.txt
cp -- -dash.txt dash-copy.txt

This workaround does work:

cat -- .\-dash.txt
grep foo -- .\-dash.txt
cp -- .\-dash.txt dash-copy.txt

I also ran into a few common GNU/POSIX forms that do not survive the wrapper:

find . \( -name "*.txt" -o -name "*.log" \) -print
find . -name "*.txt" -exec grep foo {} \;
[ -f a.txt ]
cat space\ name.txt
ls \[ab\].txt

Some of these are clearly PowerShell-vs-POSIX-shell syntax issues, so I am not claiming they are all coreutils bugs. But they are common command lines from GNU docs / muscle memory, and they are exactly the kind of cases users will try when using this project.

It would be useful either to handle the cases that can be handled, or to document the boundary of the PowerShell wrapper more explicitly. The -- -dash.txt case in particular looks like an argument-passing bug rather than just a POSIX shell compatibility limitation.

Environment:

  • Windows 10.0.26200
  • PowerShell 7.5.5
  • Wrapper source tested from commit fe33724
  • Release artifact tested: coreutils-2026.5.29-x64.exe
  • SHA256: 23B019D0664F1F5AA2A0C503435F8B52D3C8EEA2AEC1C0609CE21FCE18667281

Activity

  1. caomengxuan666 commented on Jun 3, 2026

    @caomengxuan666
    ContributorAuthor

    Um, but I would like to say that it's not coreutils' issue, it's caused by the shell. The wrapper cannot solve all of these problems. WinuxCmd project also faced the same problems. It troubles me a lot that I have to plan to move WinuxCmd into a new shell project via FFI bindings. However making a reliable shell is also another hard challenge. If this project wants to work well, it must run a test suite and identify all unsupported cases so that users and AI agents could use it. In other words, obey the Principle of Least Surprise is necessary, in my opinion. The project's boundaries need to be clearly marked.

  2. caomengxuan666 commented on Jun 3, 2026

    @caomengxuan666
    ContributorAuthor

    Small follow-up: while testing this, I think it would be useful to have a small regression harness for the PowerShell wrapper itself.

    Most of these edge cases live in pwsh-install-template.ps1, not in the individual utilities. A basic test could create a temporary command layout, load the generated wrapper snippet, and check a few representative lines such as:

    find . -name "*.txt"
    cat -- -dash.txt
    cat 'space name.txt'
    ls '[ab].txt'
    find . '(' -name "*.txt" -o -name "*.log" ')' -print

    That would make future wrapper changes less risky and help separate utility bugs from PowerShell argument-rewriting bugs.

  3. crutkas commented on Jun 9, 2026

    @crutkas
    Member

    Great catch. added to backlog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugIt shouldn't be doing this.P-backlogSomething we'd like to have added in

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions