From c6188975d2da6c1696c4433f6fce8ae4c9a6ac38 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 12 Apr 2023 08:15:20 -0300 Subject: bin/: Make help string more consistent across several executables --- bin/without-env | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'bin/without-env') 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 -- cgit v1.2.3