AikidoSec-safe-chain/packages/safe-chain
Uriel Corfa 607b4ee87d
Propagate command-not-found errors when invoking wrapped commands
Before this change, if a package manager was not installed, safe-chain still
sets the function and when invoked, the wrapper will invoke safe-chain, which
will exit with error code 127 when it fails to invoke the wrapped command. As an
example (with a shell prompt that shows $? when non-zero):

```
$ type -f pip
bash: type: pip: not found
1$ pip
127$
```

With this patch, the wrapper first checks for the existence of the wrapped
command (ignoring functions), and if no such command exists, it instructs the
shell to invoke it anyway. This results in the shell failing to find the
command, and reporting an error as if the wrapper function wasn't there:

```
$ source init-posix.sh
$ type -f pip
bash: type: pip: not found
1$ pip
Command 'pip' not found, but can be installed with:
sudo apt install python3-pip
127$
```
2026-02-11 14:23:49 +01:00
..
bin Add command to verify safe-chain is intercepting the package managers commands 2025-12-19 16:18:21 +01:00
src Propagate command-not-found errors when invoking wrapped commands 2026-02-11 14:23:49 +01:00
.npmignore Modify release process 2025-09-05 12:01:29 +02:00
package.json Fix tests and add command support 2025-12-18 10:33:31 +01:00
tsconfig.json Type check safe-chain package 2025-11-01 13:06:06 +01:00