Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PowerShell incorrectly tokenizes-i.bk when invoking external commands on Linux #26452

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

Description

@teramako

Prerequisites

Steps to reproduce

When running thesed command with the-i.bk option (to specify a backup suffix), PowerShell on Linux fails to execute the command correctly. It appears that PowerShell's command-line parser splits the-i.bk argument into multiple tokens, treating.bk as a separate argument.
This causessed to misinterpret the options and fail with an error such as:

>sed -i.bk's/foo/bar/' file.txt/usr/bin/sed: -e expression #1, char 1: unknown command: `.'

Root Cause Hypothesis

PowerShell's command-line parser may be incorrectly splitting arguments that begin with a dash (-) and contain a dot (.), assuming the dot introduces a separate token. This behavior is inconsistent with standard shell parsing and breaks compatibility with many Unix-style tools.

Expected behavior

PowerShell should pass `-i.bk` as a single argument to the external command, preserving the intended behavior of `sed`.

Actual behavior

PowerShell splits `-i.bk` into two tokens: `-i` and `.bk`, resulting in incorrect execution.#This failsin PowerShell on Linuxsed -i.bk 's/foo/bar/' file.txt#This works correctlyin bash or other shellsbash -c "sed -i.bk 's/foo/bar/' file.txt"### Result of `Trace-Command`>Trace-Command -Name CommandDiscovery,ParameterBinding -Expression { sed -i.bk's/foo/bar/' test.txt } -PSHostDEBUG: 2025-11-15 01:29:56.1475 CommandDiscovery Information: 0 : Looking up command: sedDEBUG: 2025-11-15 01:29:56.1478 CommandDiscovery Information: 0 : PATH: ...DEBUG: 2025-11-15 01:29:56.1479 CommandDiscovery Information: 0 : Looking for sed in ...(snip)DEBUG: 2025-11-15 01:29:56.1672 CommandDiscovery Information: 0 : Command Found: path (/usr/bin/sed) is an application with name: sedDEBUG: 2025-11-15 01:29:56.1674 ParameterBinding Information: 0 : BIND NAMED native application line args [/usr/bin/sed]DEBUG: 2025-11-15 01:29:56.1675 ParameterBinding Information: 0 :     BIND cmd line arg [-i] to position [0]DEBUG: 2025-11-15 01:29:56.1675 ParameterBinding Information: 0 :     BIND cmd line arg [.bk] to position [1]DEBUG: 2025-11-15 01:29:56.1676 ParameterBinding Information: 0 :     BIND cmd line arg [s/foo/bar/] to position [2]DEBUG: 2025-11-15 01:29:56.1676 ParameterBinding Information: 0 :     BIND cmd line arg [test.txt] to position [3]DEBUG: 2025-11-15 01:29:56.1682 ParameterBinding Information: 0 : CALLING BeginProcessing/usr/bin/sed: -e expression #1, char 1: unknown command: `.'

Error details

Environment data

Name                           Value---------PSVersion7.6.0-preview.5PSEdition                      CoreGitCommitId7.6.0-preview.5OS                             Ubuntu24.04.3 LTSPlatform                       UnixPSCompatibleVersions           {1.0,2.0,3.0,4.0…}PSRemotingProtocolVersion2.4SerializationVersion1.1.0.1WSManStackVersion3.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


      [8]ページ先頭

      ©2009-2025 Movatter.jp