| Crates.io | path-parents |
| lib.rs | path-parents |
| version | 1.0.3 |
| created_at | 2025-03-08 16:38:05.46576+00 |
| updated_at | 2025-03-09 22:43:26.201856+00 |
| description | Prints all the parents of each path given, optionally skipping parents up to the length specified by --skip. |
| homepage | |
| repository | https://github.com/tobinjt/path-parents |
| max_upload_size | |
| id | 1584646 |
| size | 27,798 |
path-parents prints all the parents of each path given, optionally skipping
parents up to the length specified by --skip.
path-parents is written in Rust and so needs a Rust toolchain for
installation. See https://www.rust-lang.org/tools/install for how to install
Rust. When Rust is installed path-parents can be installed with:
# This will not work until the crate is published.
cargo install path-parents
There are no pre-built binaries available, contributions to provide binaries are welcome.
$ path-parents /usr/bin/less /usr/bin/more
/usr
/usr/bin
/usr/bin/less
/usr
/usr/bin
/usr/bin/more
$ path-parents -s 1 /usr/bin/less /usr/bin/more
/usr/bin
/usr/bin/less
/usr/bin
/usr/bin/more
$ (echo /usr/bin/cat; echo /usr/bin/cut ) | path-parents
/usr
/usr/bin
/usr/bin/cat
/usr
/usr/bin
/usr/bin/cut
# Note that this will not work as you hope, and path-parents doesn't try to
# prevent you doing this because filenames can contain spaces.
$ echo /usr/bin/cat /usr/bin/cut | path-parents
/usr
/usr/bin
/usr/bin/cat
/usr/bin/cat /usr
/usr/bin/cat /usr/bin
/usr/bin/cat /usr/bin/cut
path-parents is mostly useful for expanding a path you're having trouble with
for debugging purposes. E.g. if access is denied or the file doesn't exist, you
can figure out where the problem is with:
ls -l -d $(path-parents /path/with/problems)
E.g.:
$ ls -l -d $(path-parents /opt/homebrew/Cellar/rustup/*/share/zsh/site-functions/_rustup)
drwxr-xr-x 3 root wheel 96 10 Dec 2022 /opt/
drwxr-xr-x 33 johntobin admin 1056 28 Feb 22:00 /opt/homebrew/
drwxrwxr-x 151 johntobin admin 4832 8 Feb 15:36 /opt/homebrew/Cellar/
drwxr-xr-x@ 3 johntobin admin 96 8 Mar 14:59 /opt/homebrew/Cellar/rustup/
drwxr-xr-x@ 14 johntobin admin 448 8 Mar 14:59 /opt/homebrew/Cellar/rustup/1.28.1/
drwxr-xr-x@ 4 johntobin admin 128 5 Mar 11:33 /opt/homebrew/Cellar/rustup/1.28.1/share/
drwxr-xr-x@ 3 johntobin admin 96 5 Mar 11:33 /opt/homebrew/Cellar/rustup/1.28.1/share/zsh/
drwxr-xr-x@ 3 johntobin admin 96 5 Mar 11:33 /opt/homebrew/Cellar/rustup/1.28.1/share/zsh/site-functions/
-rw-r--r--@ 1 johntobin admin 55464 5 Mar 11:33 /opt/homebrew/Cellar/rustup/1.28.1/share/zsh/site-functions/_rustup
If there permission problems or missing files it will be easy to see where the problem starts.
Licensed under the Apache 2.0 licence, see the LICENSE file
accompanying the software.