nushell/crates/nu-command/src/filesystem
Sebastian Nallar cb57f0a539
Add --follow-symlinks flag to glob command (fixes #15559) (#15626)
Fixes #15559

# Description
The glob command wasn't working correctly with symlinks in the /sys
filesystem. This commit adds a new flag that allows users to explicitly
control whether symlinks should be followed, with special handling for
the /sys directory.

The issue was that the glob command didn't follow symbolic links when
traversing the /sys filesystem, resulting in an empty list even though
paths should be found. This implementation adds a new
`--follow-symlinks` flag that explicitly enables following symlinks. By
default, it now follows symlinks in most paths but has special handling
for /sys paths where the flag is required.

Example:
`
# Before: This would return an empty list on Linux systems
glob /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

# Now: This works as expected with the new flag
glob /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
--follow-symlinks
`

# User-Facing Changes

1. Added the --follow-symlinks (-l) flag to the glob command that allows
users to explicitly control whether symbolic links should be followed
2. Added a new example to the glob command help text demonstrating the
use of this flag

# Tests + Formatting

1. Added a test for the new --follow-symlinks flag
2025-04-23 10:47:48 -05:00
..
cd.rs fix(nu-command): support ACL, SELinux, e.g. in cd have_permission check (#15360) 2025-03-27 14:23:41 +01:00
du.rs check signals in nu-glob and ls (#15140) 2025-02-28 19:36:39 +01:00
glob.rs Add --follow-symlinks flag to glob command (fixes #15559) (#15626) 2025-04-23 10:47:48 -05:00
ls.rs Fix clippy (#15489) 2025-04-06 09:49:28 +08:00
mktemp.rs Refactor I/O Errors (#14927) 2025-01-28 16:03:31 -06:00
mod.rs Make utouch the new touch (#14721) 2025-01-02 06:26:46 -06:00
open.rs fix: command open sets default flags when calling "from xxx" converters (#15383) 2025-03-25 17:40:20 +01:00
rm.rs Fix future clippy lints (#15519) 2025-04-08 08:51:12 +08:00
save.rs bump the rust toolchain to 1.83.0 (#15148) 2025-02-20 16:34:09 -06:00
start.rs non-HTTP(s) URLs now works with start (#14370) 2025-01-23 17:14:31 -08:00
ucp.rs check signals in nu-glob and ls (#15140) 2025-02-28 19:36:39 +01:00
umkdir.rs Remove duplicate implementations of CallExt::rest (#14484) 2024-12-01 15:03:45 +01:00
umv.rs check signals in nu-glob and ls (#15140) 2025-02-28 19:36:39 +01:00
util.rs Remove duplicate implementations of CallExt::rest (#14484) 2024-12-01 15:03:45 +01:00
utouch.rs Remove nu-glob's dependency on nu-protocol (#15349) 2025-03-20 17:32:41 +01:00
watch.rs Refactor I/O Errors (#14927) 2025-01-28 16:03:31 -06:00