Crates.io | globcmp |
lib.rs | globcmp |
version | 0.3.0 |
created_at | 2025-09-10 22:57:29.159736+00 |
updated_at | 2025-09-10 22:57:29.159736+00 |
description | globcmp assesses whether one glob pattern matches a file path more closely than another glob pattern does. |
homepage | https://github.com/gn0/globcmp |
repository | https://github.com/gn0/globcmp |
max_upload_size | |
id | 1833112 |
size | 20,224 |
globcmp assesses whether one glob pattern matches a file path more closely than another glob pattern does.
globcmp can be used either as a standalone executable or as a dependency for other crates. If you want to use it as a dependency, see the globcmp-lib crate.
Install via crates.io:
cargo install --locked globcmp
Or from the GitHub repository:
cargo install --locked --git https://github.com/gn0/globcmp.git
If $HOME/.cargo/bin
is not in your PATH
environment variable, then you also need to run:
export PATH=$HOME/.cargo/bin:$PATH
To make this setting permanent:
echo 'export PATH=$HOME/.cargo/bin:$PATH' >> $HOME/.bashrc # If using bash.
echo 'export PATH=$HOME/.cargo/bin:$PATH' >> $HOME/.zshrc # If using zsh.
This crate has one feature flag, stack-safe
(off by default).
globcmp's pattern matching algorithms rely heavily on recursion, so they can in principle overflow the stack and panic.
If compiled with the stack-safe
feature flag turned on, globcmp uses the stacker crate to allocate memory on the heap if the stack space is about to run out.
There is a performance cost to checking the available stack space each time the algorithm recurs.
For the executable provided by the globcmp crate, you most likely won't need to turn on stack-safe
.
If you use the globcmp-lib crate as a dependency, you might.
globcmp 'foo/bar' 'foo/bar' # Prints: same
globcmp 'foo/bar' 'foo/b?r' # Prints: pattern_a
globcmp 'foo/b*r' 'foo/b?r' # Prints: pattern_b
globcmp 'foo/b*r' 'foo/asd' # Prints: unknown
globcmp is distributed under the GNU Lesser General Public License (LGPL), version 3. See the file LICENSE for more information.