Skip to content

Commit

Permalink
Merge pull request ocaml#4971 from kit-ty-kate/cmd-not-found
Browse files Browse the repository at this point in the history
Print user-friendly error messages when a command is not found, before calling the sandbox
  • Loading branch information
rjbou committed Apr 22, 2022
1 parent 4e775d1 commit a78aa33
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ New option/command/subcommand are prefixed with ◈.

## Sandbox
*
* Sync the behaviour of the macOS sandbox script with Linux's: /tmp is now ready-only [#4719 @kit-ty-kate]
* Always mount every directories under / on Linux [#4795 @kit-ty-kate]
* Get rid of OPAM_USER_PATH_RO (never used on macOS and no longer needed on Linux) [#4795 @kit-ty-kate]
* Print error message if command doesn't exist [#4971 @kit-ty-kat - fix #4112]

## Repository management
*
Expand Down
5 changes: 5 additions & 0 deletions src/state/shellscripts/bwrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ case "$COMMAND" in
exit 2
esac

if ! command -v "$1" >/dev/null; then
echo "[ERROR] Command not found: $1" >&2
exit 10
fi

# Note: we assume $1 can be trusted, see https://github.com/projectatomic/bubblewrap/issues/259
# As of now we are compatible up to 0.1.8, '--' can be added here when we require >= 0.3.0
exec bwrap "${ARGS[@]}" "$@"
5 changes: 5 additions & 0 deletions src/state/shellscripts/sandbox_exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,9 @@ case "$COMMAND" in
exit 2
esac

if ! command -v "$1" >/dev/null; then
echo "[ERROR] Command not found: $1" >&2
exit 10
fi

exec sandbox-exec -p "$POL" "$@"

0 comments on commit a78aa33

Please sign in to comment.