globcmp

Crates.ioglobcmp
lib.rsglobcmp
version0.3.0
created_at2025-09-10 22:57:29.159736+00
updated_at2025-09-10 22:57:29.159736+00
descriptionglobcmp assesses whether one glob pattern matches a file path more closely than another glob pattern does.
homepagehttps://github.com/gn0/globcmp
repositoryhttps://github.com/gn0/globcmp
max_upload_size
id1833112
size20,224
Gábor Nyéki (gn0)

documentation

README

globcmp

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.

Installation

Instructions

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.

Feature flag: stack safety

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.

Usage

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

License

globcmp is distributed under the GNU Lesser General Public License (LGPL), version 3. See the file LICENSE for more information.

Commit count: 20

cargo fmt