Note: This document describes Unix-like systems, but similar approaches can be applied to Windows as well. Pull requests adding recipes for Windows are welcome.
The recommended way is to use a shell alias:
alias cargo="cargo auditable"
When entered into the shell, it will only persist for the duration of the session. To make the change permanent, add it to your shell's configuration file (.bashrc
for bash, .zshrc
for zsh, .config/fish/config.fish
for fish).
In some cases using shell aliases is not an option, e.g. in certain restricted build environments. In this case you can use a different approach:
- Run
which cargo
to locate the Cargo binary - Copy the snippet provided below and replace '/path/to/cargo' with the path you got at step 1
- Save it to a file named
cargo
- Run
chmod +x cargo
to make the script executable - Prepend the path to the directory where you saved the script to your
PATH
environment variable. For example, if you saved the script as$HOME/.bin/cargo
, you need to add$HOME/.bin/
to yourPATH
. The exact way to do this varies depending on the shell; in bash it'sexport PATH="$HOME/.bin/:$PATH"
#!/bin/sh
export CARGO='/path/to/real/cargo' # replace this with your path
cargo-auditable auditable "$@"