Skip to content

Native globbing on Unix lacks ability to include hidden items #4683

@mklement0

Description

@mklement0

Get-Item and Get-ChildItem have the -Force switch for including hidden items in the enumeration / matching of item names.

Currently, there is no analog when calling an external utility with a glob (wildcard pattern) argument.

Unfortunately, it looks like the only way to provide this ability would be via a new preference variable.

In bash, it is shell option dotglob that controls whether hidden items are included or not.

Current behavior

# Create temp. dir. for easy experimentation.
Push-Location (New-Item -Force -ItemType Directory -Path ($tmpDir = [io.Path]::GetTempPath() + "globtest.$PID"))
# Create a regular and a hidden file.
$null = New-Item -Force -Path 'a', '.a' -ItemType File


# This currently returns only 'a', 
# with no way to opt into returning the hidden '.a' file too.
' --- printf *'
printf '%s\n' *

# With Get-Item/Get-ChildItem, using -Force opts into including hidden items.
' --- Get-Item -Force *'
Get-Item -Force * | % Name

# Remove temp. dir.
Pop-Location
Remove-Item -Force -Recurse $tmpDir

Environment data

PowerShell Core v6.0.0-beta.6 on macOS 10.12.6
PowerShell Core v6.0.0-beta.6 on Ubuntu 16.04.3 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FileSystem-Providerspecific to the FileSystem providerIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management moduleWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions