mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Merge pull request #282 from uriel-ecosia/command-not-found
Propagate command-not-found errors when invoking wrapped commands
This commit is contained in:
commit
f358709ab2
2 changed files with 24 additions and 2 deletions
|
|
@ -90,6 +90,20 @@ function wrapSafeChainCommand
|
||||||
set original_cmd $argv[1]
|
set original_cmd $argv[1]
|
||||||
set cmd_args $argv[2..-1]
|
set cmd_args $argv[2..-1]
|
||||||
|
|
||||||
|
if not type -fq $original_cmd
|
||||||
|
# If the original command is not available, don't try to wrap it: invoke
|
||||||
|
# it transparently, so the shell can report errors as if this wrapper
|
||||||
|
# didn't exist. fish always adds extra debug information when executing
|
||||||
|
# missing commands from within a function, so after the "command not
|
||||||
|
# found" handler, there will be information about how the
|
||||||
|
# wrapSafeChainCommand function errored out. To avoid users assuming this
|
||||||
|
# is a safe-chain bug, display an explicit error message afterwards.
|
||||||
|
command $original_cmd $cmd_args
|
||||||
|
set oldstatus $status
|
||||||
|
echo "safe-chain tried to run $original_cmd but it doesn't seem to be installed in your \$PATH." >&2
|
||||||
|
return $oldstatus
|
||||||
|
end
|
||||||
|
|
||||||
if type -q safe-chain
|
if type -q safe-chain
|
||||||
# If the safe-chain command is available, just run it with the provided arguments
|
# If the safe-chain command is available, just run it with the provided arguments
|
||||||
safe-chain $original_cmd $cmd_args
|
safe-chain $original_cmd $cmd_args
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,14 @@ function printSafeChainWarning() {
|
||||||
function wrapSafeChainCommand() {
|
function wrapSafeChainCommand() {
|
||||||
local original_cmd="$1"
|
local original_cmd="$1"
|
||||||
|
|
||||||
|
if ! type -f "${original_cmd}" > /dev/null 2>&1; then
|
||||||
|
# If the original command is not available, don't try to wrap it: invoke it
|
||||||
|
# transparently, so the shell can report errors as if this wrapper didn't
|
||||||
|
# exist.
|
||||||
|
command "$@"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
if command -v safe-chain > /dev/null 2>&1; then
|
if command -v safe-chain > /dev/null 2>&1; then
|
||||||
# If the aikido command is available, just run it with the provided arguments
|
# If the aikido command is available, just run it with the provided arguments
|
||||||
safe-chain "$@"
|
safe-chain "$@"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue