mongo/.devcontainer/xdg-open-wrapper.sh
Eric Lavigne 55bc36a85b SERVER-112612: Add xdg-open wrapper to open browser urls on the host (#43174)
GitOrigin-RevId: 277d7824e33d5e863beafa339fdcfa723a119794
2025-10-27 17:28:18 +00:00

21 lines
589 B
Bash
Executable File

#!/bin/bash
# xdg-open wrapper for devcontainer
# Launches URLs using VSCode's $BROWSER environment variable
# Falls back to native xdg-open for non-URLs
NATIVE_XDG_OPEN="/usr/bin/xdg-open.real"
# If it's an HTTP/HTTPS URL and $BROWSER is set, use it
if [[ "$1" == http:* || "$1" == https:* ]] && [ -n "$BROWSER" ]; then
exec "$BROWSER" "$@"
fi
# Otherwise, fall back to native xdg-open if it exists
if [ -x "$NATIVE_XDG_OPEN" ]; then
exec "$NATIVE_XDG_OPEN" "$@"
fi
# If we get here, we couldn't handle it
echo "Error: Cannot open '$1' - no suitable handler found" >&2
exit 1