PowerShell / PowerShell/PowerShell

Select-String highlighting / emphasis only works on first Select-String

Open
#20,062 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Prerequisites
Steps to reproduce

The highlighting / emphasis from Select-String is only done for the first instance of Select-String in the pipeline. It should be the last since it is a highlighting technique.

Expected behavior
PowerShell 7.3.6

[C:\Users\lee]
PS:1 > "Hello World" | Select-String Hello

>>Hello<< World


[C:\Users\lee]
PS:2 > "Hello World" | Select-String World

Hello >>World<<


[C:\Users\lee]
PS:3 > "Hello World" | Select-String Hello | Select-String World

Hello >>World<<


[C:\Users\lee]
PS:4 > "Hello World" | Select-String Hello -NoEmphasis | Select-String World

Hello >>World<<
Actual behavior
PowerShell 7.3.6

[C:\Users\lee]
PS:1 > "Hello World" | Select-String Hello

>>Hello<< World


[C:\Users\lee]
PS:2 > "Hello World" | Select-String World

Hello >>World<<


[C:\Users\lee]
PS:3 > "Hello World" | Select-String Hello | Select-String World

>>Hello<< World


[C:\Users\lee]
PS:4 > "Hello World" | Select-String Hello -NoEmphasis | Select-String World

Hello World
(no highlighting / emphasis at all)
Error details

No response

Environment data
Name                           Value
----                           -----
PSVersion                      7.3.6
PSEdition                      Core
GitCommitId                    7.3.6
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visuals
image

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

Start by reproducing the four Select-String pipeline examples from the issue and trace how emphasis is carried between successive Select-String commands. Done means the final Select-String controls the highlighting, while -NoEmphasis on the first command does not suppress emphasis from the later command.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.