summaryrefslogtreecommitdiff
path: root/bin/emacsclient
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-11-14 10:37:48 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-11-14 22:06:09 -0700
commitaf51771de201d07b833dee29db9487c5a4efa5d3 (patch)
tree45c0bd5e4115ad66ccc05113f088d998050bdd8f /bin/emacsclient
parentf8cac7b64fe02ec7f41978c4fb4bf283ef13bd89 (diff)
downloaddotfiles-af51771de201d07b833dee29db9487c5a4efa5d3.tar.gz
emacsclient wrapper: don't fail completely if bash not on PATH
Diffstat (limited to 'bin/emacsclient')
-rwxr-xr-xbin/emacsclient28
1 files changed, 14 insertions, 14 deletions
diff --git a/bin/emacsclient b/bin/emacsclient
index 97d8242d..89c76443 100755
--- a/bin/emacsclient
+++ b/bin/emacsclient
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Copyright (C) 2022 Sean Whitton
#
@@ -35,6 +35,19 @@ daemon_name=
gdbmacs=
args=
+devel_emacs="$HOME/src/emacs/src/emacs"
+devel_emacsclient="$HOME/src/emacs/lib-src/emacsclient"
+
+installed_emacs=$(command -v emacs)
+installed_emacsclient=$(PATH=$(echo "$PATH" \
+ | sed -e "s#$HOME/src/dotfiles/bin:##") \
+ command -v emacsclient)
+
+for cmd in bash flock inotifywait perl pwdx ss; do
+ command -v $cmd >/dev/null || exec "$installed_emacsclient" -a "" "$@"
+done
+[ -n "$BASH_VERSION" ] || exec bash "$0" "$@"
+
get_listener () {
local socket="$1"
local listener=$(ss -Hplx src "$socket" \
@@ -97,19 +110,6 @@ done
# -sgdbmacs implies --spw/installed, as a special case.
[ "$daemon_name" = gdbmacs ] && want_installed=true
-devel_emacs="$HOME/src/emacs/src/emacs"
-devel_emacsclient="$HOME/src/emacs/lib-src/emacsclient"
-
-installed_emacs=$(command -v emacs)
-installed_emacsclient=$(PATH=$(echo "$PATH" \
- | sed -e "s#$HOME/src/dotfiles/bin:##") \
- command -v emacsclient)
-
-for external in flock inotifywait perl pwdx ss; do
- command -v $external >/dev/null \
- || exec -a emacsclient "$installed_emacsclient" -a "" "$@"
-done
-
# We set and export XDG_RUNTIME_DIR such that Emacs doesn't choose
# "/tmp/emacs$(id -u)" as the socket dir.
if [ -n "$XDG_RUNTIME_DIR" ]; then