From 6c4423c737d9afdbb6db3c7eb1c795d0277ce465 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 13 Jan 2023 09:32:15 -0700 Subject: emacsclient wrapper: use 'exec -a' when giving up and have bash Also, reexecute with bash first to avoid checking the other commands twice. --- bin/emacsclient | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bin/emacsclient') diff --git a/bin/emacsclient b/bin/emacsclient index 12630575..b980860b 100755 --- a/bin/emacsclient +++ b/bin/emacsclient @@ -55,13 +55,18 @@ defer () { esac done $may_start && set -- -a "" "$@" - exec "$installed_emacsclient" "$@" + if [ -n "$BASH_VERSION" ]; then + exec -a emacsclient "$installed_emacsclient" "$@" + else + exec "$installed_emacsclient" "$@" + fi } -for cmd in bash flock inotifywait perl pwdx ss; do +[ -n "$BASH_VERSION" ] \ + || { command -v bash >/dev/null && exec bash "$0" "$@" || defer "$@"; } +for cmd in flock inotifywait perl pwdx ss; do command -v $cmd >/dev/null || defer "$@" done -[ -n "$BASH_VERSION" ] || exec bash "$0" "$@" # We have to do this to break up clustered short options. An unfortunate # consequence is maintaining a copy of all of emacsclient(1)'s long opts here. -- cgit v1.2.3