From af51771de201d07b833dee29db9487c5a4efa5d3 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 14 Nov 2022 10:37:48 -0700 Subject: emacsclient wrapper: don't fail completely if bash not on PATH --- bin/emacsclient | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'bin/emacsclient') 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 -- cgit v1.2.3