Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ private void PossiblyGlobArg(string arg, bool usedQuotes)
// If it's a filesystem location then expand the wildcards
if (cwdinfo.Provider.Name.Equals(FileSystemProvider.ProviderName, StringComparison.OrdinalIgnoreCase))
{
// On UNIX, paths starting with ~ are not normalized
bool normalizePath = arg.Length == 0 || arg[0] != '~';
// On UNIX, paths starting with ~ or absolute paths are not normalized
bool normalizePath = arg.Length == 0 || ! (arg[0] == '~' || arg[0] == '/');

// See if there are any matching paths otherwise just add the pattern as the argument
Collection<PSObject> paths = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ Describe 'Native UNIX globbing tests' -tags "CI" {

$a = $v,$v
/bin/ls $a[1] | Should -Match "abc.txt"
}
}
# Test globbing with absolute paths - it shouldn't turn absolute paths into relative paths (#7089)
It 'Should not normalize absolute paths' {
$matches = /bin/echo /etc/*
# Matched path should start with '/etc/' not '../..'
$matches.substring(0,5) | Should Be '/etc/'
}
It 'Globbing should not happen with quoted expressions' {
$v = "$TESTDRIVE/abc*"
/bin/echo "$v" | Should -BeExactly $v
Expand Down