diff options
author | EuAndreh <eu@euandre.org> | 2023-04-12 08:15:20 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-04-12 08:15:20 -0300 |
commit | c6188975d2da6c1696c4433f6fce8ae4c9a6ac38 (patch) | |
tree | 613545634bc999385d13ecb107d2cce113ba11c4 /bin/without-env | |
parent | bin/: Add trailing semicolor to Perl heredocs (diff) | |
download | dotfiles-c6188975d2da6c1696c4433f6fce8ae4c9a6ac38.tar.gz dotfiles-c6188975d2da6c1696c4433f6fce8ae4c9a6ac38.tar.xz |
bin/: Make help string more consistent across several executables
Diffstat (limited to 'bin/without-env')
-rwxr-xr-x | bin/without-env | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/bin/without-env b/bin/without-env index 57c2d2e..4e7ed15 100755 --- a/bin/without-env +++ b/bin/without-env @@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - without-env ENVVAR PATH -- COMMAND... + without-env ENVVAR PATH COMMAND... without-env -h EOF } @@ -12,17 +12,30 @@ usage() { help() { cat <<-'EOF' + Options: -h, --help show this message + ENVVAR the name of the environment variable to be modifed + PATH section to be excluded from ENVVAR + COMMAND command to be wrapped + + + Execute COMMAND, but changing the variable ENVVAR by excluding + PATH from it. + + Examples: Execute "command -V" filtering ~/bin, to get where "w3m" is in $PATH, other than ~/bin: + $ without-env PATH ~/bin -- command -v w3m + Compile foo.c, excluding ~/.local/include from $C_INCLUDE_PATH: + $ without-env C_INCLUDE_PATH ~/.local/include -- cc -co foo.o foo.c EOF } @@ -60,7 +73,7 @@ shift $((OPTIND - 1)) eval "$(assert-arg -- "${1:-}" 'ENVVAR')" eval "$(assert-arg -- "${2:-}" 'PATH')" -eval "export $1=\"\$(echo \"\$$1\" | sed \"s|\$2:||g\")\"" +eval "export $1=\"\$(echo \"\$$1\" | sed \"s|\$2||g\")\"" shift # drop $1 shift # drop $2 if [ "${1:-}" = '--' ]; then |