summaryrefslogtreecommitdiff
path: root/bin/emacsclient
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-02-03 09:55:04 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-02-03 09:55:04 -0700
commitb5273895f001a4d7e96c0e78d2048ed4b3b1e9b3 (patch)
tree8c30cb18e8ed13d158c0e7d422e8ab676160d808 /bin/emacsclient
parenta420066aaae0d4a5d1804673d823ca49dd4f2503 (diff)
downloaddotfiles-b5273895f001a4d7e96c0e78d2048ed4b3b1e9b3.tar.gz
emacsclient wrapper: don't call realpath & ss on non-existent socket
Diffstat (limited to 'bin/emacsclient')
-rwxr-xr-xbin/emacsclient10
1 files changed, 3 insertions, 7 deletions
diff --git a/bin/emacsclient b/bin/emacsclient
index 5279effd..ff6b071e 100755
--- a/bin/emacsclient
+++ b/bin/emacsclient
@@ -83,7 +83,7 @@ eval set -- "$getopt"
get_listener () {
local socket=$1 listener= listener_age= rematch_listener= rematch_age=
# Find the youngest process listening on a socket of this name.
- while read -r line; do
+ [ -e "$socket" ] && while read -r line; do
[[ $line =~ ,pid=([[:digit:]]+), ]] || continue
rematch_listener=${BASH_REMATCH[1]}
rematch_age="$(ps h -o etimes $rematch_listener)"
@@ -94,12 +94,8 @@ get_listener () {
listener_age=$rematch_age
fi
done < <(ss -plx src "$(realpath "$socket")")
- if [ -z "$listener" -a -e "$socket" ]; then
- # Nothing is listening: remove dangling socket.
- rm "$socket"
- else
- echo "$listener"
- fi
+ # If nothing is listening, remove any dangling socket.
+ [ -n "$listener" ] && echo "$listener" || rm -f "$socket"
}
gud_status () {