Skip to content

Instantly share code, notes, and snippets.

@hdonnay
Created March 16, 2022 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hdonnay/35775a72f443b6c226a49cb51617e2a3 to your computer and use it in GitHub Desktop.
Save hdonnay/35775a72f443b6c226a49cb51617e2a3 to your computer and use it in GitHub Desktop.
#!/bin/sh
### onhost is the inverse of intoolbox -- it attempts to run a command on the
### host if invoked from inside a toolbox.
###
### It should be symlinked as the name of the command to call:
### ln -s `which _onhost` podman
### ./podman
set -e
cmd="$(basename "$0")"
if [ "$cmd" = '_onhost' ]; then
sed -En 's/^### ?//;T;p' "$0"
exit 1
fi
if test -f /run/.containerenv; then
exec flatpak-spawn --host "${cmd}" "$@"
fi
exec command -p "$cmd" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment