You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Linux: cd and find commands fail when a colon is in the directory or file name #4889
The /sys and /proc directories have sub-directories with colons in the names. Commands like cd and find fail when trying to access directories with ':'.
PS /> cd /sys/devices/pci0000:00/
cd : Cannot find drive. A drive with the name 'sys/devices/pci0000' does not exist.
At line:1 char:1
This is not quite a dup of 3931 as it's not exclusively about wildcard expansion and quoting. The command cd /sys/devices/pci0000:00/ should work but it fails because we're treating everything before the colon as a drive name. To fix this, we should probably restrict the set of characters allowed in drive names to be alphanumeric (a breaking change but necessary I think for *nix platforms). Also, the default drive for the file system on *nix is '/' which can't actually be used e.g. ls /: doesn't work. We should change it to be a "real" drive name like root: or some such.
Bruce Payette (@BrucePay) is the second example find /sys -name ':' not the same as #4870 and #3931? I missed that the first example was using the cd alias.
The drive name is extracted first in order to determine what provider to pass the remainder of the string to. Based on the cd example above, it appears that the code just scans the string until it hits a colon. Restricting the drive name to alphanumerics would cover a lot of cases (e.g. the cd above) but not your specific one. Prefixing with ./ is one workaround e.g. cd ./pci0000:00 or you could specify the actual drive cd root:pci0000:00 (assuming we pre-created a drive "root" of the file system instead of '/' which can't actually be used.) Note: New-PSDrive won't let you create a drive with any of ; ~ / \ . : in the name but we apparently aren't universal in our checks.
Activity
markekraus commentedon Sep 21, 2017
Dupe of #3931BrucePay commentedon Sep 21, 2017
This is not quite a dup of 3931 as it's not exclusively about wildcard expansion and quoting. The command
cd /sys/devices/pci0000:00/should work but it fails because we're treating everything before the colon as a drive name. To fix this, we should probably restrict the set of characters allowed in drive names to be alphanumeric (a breaking change but necessary I think for *nix platforms). Also, the default drive for the file system on *nix is '/' which can't actually be used e.g.ls /:doesn't work. We should change it to be a "real" drive name likeroot:or some such.markekraus commentedon Sep 21, 2017
Bruce Payette (@BrucePay) is the second example
find /sys -name ':'not the same as #4870 and #3931? I missed that the first example was using thecdalias.BrucePay commentedon Sep 21, 2017
Mark Kraus (@markekraus) Yes the second example is the same as 3931.
lzybkr commentedon Sep 21, 2017
Bruce Payette (@BrucePay) - does restricting characters in the drive name? Consider:
In other words - I thought parsing out the drive name happened early in path parsing before trying to resolve the filename portion of the path.
BrucePay commentedon Sep 21, 2017
The drive name is extracted first in order to determine what provider to pass the remainder of the string to. Based on the
cdexample above, it appears that the code just scans the string until it hits a colon. Restricting the drive name to alphanumerics would cover a lot of cases (e.g. the cd above) but not your specific one. Prefixing with ./ is one workaround e.g.cd ./pci0000:00or you could specify the actual drivecd root:pci0000:00(assuming we pre-created a drive "root" of the file system instead of '/' which can't actually be used.) Note: New-PSDrive won't let you create a drive with any of; ~ / \ . :in the name but we apparently aren't universal in our checks.