Verify tools are on your system and see their versions at a
glance.
A Rust port of the original
has bash script.
What is has-rs?
has-rs checks for the presence of
command-line tools are available on your system (e.g. in
your
PATH) and reports their installed version. Pass it any
number of program names and it will tell you exactly
which ones are present and which are not.
Additionally, because a missing (non-optional) program
causes it to return with a non-zero
exit code, it can also be used in scripts that expect a program
to be present, or even a program of a certain version.
It is designed to be a
drop-in replacement for the original
has bash
script (referred to as "has-bash" to reduce confusion)
but it also includes some great new features,
quality of life improvements, and maybe even some
bugfixes.
Some common uses:
Guarding a script with a quick dependency check
before it runs
Committing a .hasrc file so
contributors can verify their environment
Quickly auditing a fresh machine or container
Installation
Pre-built binaries
Linux and Windows builds are available on
the
releases page. Download the archive for your platform, extract the
has binary, and place it somewhere on your
PATH.
Releases are compatible with tools like
eget2 that
can install binaries directly from Forgejo/Gitea
releases.
Beyond parity with has-bash, has-rs ships a few
additional features:
🔓 --allow-unsafe
Attempt to detect unknown tools via
--version, as a flag rather than
only an env variable.
🔀 Alternates
Check for one tool or another. Only
counts as a failure if none are
present.
❓ Optional programs
Mark a tool optional with ?; a
missing optional tool never increments the exit
code.
💬 Inline .hasrc comments
End-of-line comments in .hasrc are
stripped, so you can annotate entries inline.
💬 Inline .hasrc comments
End-of-line comments in .hasrc are
stripped, so you can annotate entries inline.
Supported programs
Below is a complete list of programs that will be detected without having to
use HAS_ALLOW_UNSAFE=y or --allow-unsafe.
(Wondering what a program is? Hover over for a tooltip!)
ab
ack
act
ag
ant
apt
apt-get
aptitude
aria2c
autojump
awk
aws
bash
bats
brew
brunch
bun
bundle
bzip2
bzr
cargo
ccache
clang
cmake
code
codium
composer
conda
consul
curl
deno
docker
docker-compose
eb
emacs
file
firefox
fish
g++
gcc
gcloud
gem
git
gnu_coreutils
go
gor
gpg
gpg-agent
gpgconf
gpg-connect-agent
gpgsm
gradle
grep
groovy
groovyConsole
grunt
gulp
gunzip
gzip
has
heroku
hg
htop
http
hub
hugo
java
javac
jq
just
kotlin
lein
make
mvn
mysql
nano
netlify
netlifyctl
ninja
node
nomad
npm
npx
openssl
packer
perl
perl6
php
php5
pip
pip3
pipenv
pnpm
podman
poetry
psql
pv
python
python3
R
rake
rg
ruby
rustc
sbt
scala
screen
sed
shellcheck
sls
sqlite3
ssh
subl
sudo
svn
tar
tee
terraform
tig
tmux
tree
unar
unrar
unzip
uv
vagrant
vim
vite
wget
xz
yarn
yq
zig
zip
zsh
If you think you have a program that is worth adding, feel free to
submit an issue!
Differences from has-bash
has-rs aims to be as compatible with the bash version as is reasonable.
The list below covers everything that is intentionally different.
Behaviour
has-rs
has-bash
Help output format
clap-style (--help)
different
custom hand-written help
Version output
has 0.2.3different
v1.5.2
Quiet flag
-q and --quietnew
-q only
.hasrc comments
Supports end-of-line
new
Full-line only
Allowing unknown programs
--allow-unsafenew
HAS_ALLOW_UNSAFE env var
only
Bypassing .hasrc
--no-rcnew
.hasrc is always read
Alternate programs
Separated with "|"new
Not supported
Optional programs
End with "?"new
Not supported
Suppressing soft errors
--hide-optionalnew
N/A
Backwards compatibility
has-bash alias
new
N/A
Unsafe mode as compile-time default
always-allow-unsafe feature
new
Not available
Additionally, here are the programs that has-rs either newly supports or has improved upon over has-bash
(as of v1.5.2):
CI: Releases are now compatible with programs that install binaries like eget2 or distillery!
Note that distillery does not yet support Codeberg, but I'm working on creating a PR for that! 🤞
CI: Releases will now include Linux (musl and GNU) and Windows (x86 and ARM)!
Will work on getting Linux ARM soon!
Change: has-rs now always captures stderr; this aligns with how has-bash acts, but it might cause behavioral changes in non-officially supported programs
I cannot remember quite why I made this difference in the first place tbh