diff options
author | Chuck Lantz <clantz@microsoft.com> | 2022-12-16 20:47:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-16 20:47:21 +0300 |
commit | bf058dc49492b3a102a28ed25764a517fcebfb40 (patch) | |
tree | 6ccc831064fab57ea6fa2f0c530202ac0d73ff08 /src/common-utils/bin/code | |
parent | 7fa90110d762797cc0b1c2fe8fcc028c9b813d56 (diff) |
Multi-distro support for common script, refactor, fixes (#326)
Diffstat (limited to 'src/common-utils/bin/code')
-rwxr-xr-x | src/common-utils/bin/code | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common-utils/bin/code b/src/common-utils/bin/code new file mode 100755 index 0000000..b0d517f --- /dev/null +++ b/src/common-utils/bin/code @@ -0,0 +1,16 @@ +#!/bin/sh + +get_in_path_except_current() { + which -a "$1" | grep -A1 "$0" | grep -v "$0" +} + +code="$(get_in_path_except_current code)" + +if [ -n "$code" ]; then + exec "$code" "$@" +elif [ "$(command -v code-insiders)" ]; then + exec code-insiders "$@" +else + echo "code or code-insiders is not installed" >&2 + exit 127 +fi |