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
Checking whether one path is inside another (as in '/home/me/Documents is inside /home/me') is a simple, reasonably common task with several possible ways to do it, some of which are subtly unreliable. It would be nice to standardize it.
Considering the current push towards Rust, which would be kept simple by minimizing added functionality, I'll just put a basic fish implementation here for the moment :
function path-inside --description 'return paths which are inside $argv[1]'
set -l parent (path resolve -- $argv[1])/
set -l plen (string length -- $parent)
set -l nunpassed 0
for p in $argv[2..]
if [ (string sub -l $plen -- (path resolve -- $p)) = $parent ]
printf %s\n $p
else
set nunpassed (math $nunpassed+1)
end
end
[ $nunpassed -lt (count $argv[2..]) ]
end
The text was updated successfully, but these errors were encountered:
Checking whether one path is inside another (as in '/home/me/Documents is inside /home/me') is a simple, reasonably common task with several possible ways to do it, some of which are subtly unreliable. It would be nice to standardize it.
Considering the current push towards Rust, which would be kept simple by minimizing added functionality, I'll just put a basic fish implementation here for the moment :
The text was updated successfully, but these errors were encountered: