Skip to content

No-argument tab-completion fails with Get-Process on macOS, possibly due to process objects lacking a ProcessName property #7174

@mklement0

Description

@mklement0

Steps to reproduce

On macOS, try the following:

Get-Process  # < -- press <tab> here (whether once or multiple times makes no difference)

On Windows and Linux you get the names of all running processes, but on macOS nothing happens.

Expected behavior

A list (menu) of the names of all running processes.

Actual behavior

Nothing happens at all.

The problem goes away once you've typed at least prefix char. of the process name to match.

Presumed cause:

On macOS, many processes output by Get-Process lack a .Name aka .ProcessName value.

As an aside: Is that expected or a bug in itself?

It seems that these entries without a .Name value cause the problem when the list of completions is constructed:

@lzybkr provided the following code to diagnose the problem, which simulates what happens when you tab-complete, while also surfacing exceptions:

$line = "Get-Process "  # Simulate `Get-Process <tab>`
TabExpansion2 $line $line.Length

The above, rather than outputting a [System.Management.Automation.CommandCompletion] object with all process names, reports the following error:

Exception calling "CompleteInput" with "3" argument(s): "Cannot process argument because the value of argument "listItemText" is null. Change the value of argument "listItemText"
...

Environment data

PowerShell Core v6.1.0-preview.3 on macOS 10.13.5

Metadata

Metadata

Assignees

Labels

Resolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions