File tree Expand file tree Collapse file tree 1 file changed +19
-16
lines changed
Expand file tree Collapse file tree 1 file changed +19
-16
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env sh
2+ set -eu
23
3- failed_to_kill () {
4- [ " ${1-} " != " -q" ] && echo " Failed to kill the RESH daemon - it probably isn't running"
5- }
4+ q=0
5+ [ " ${1-} " != " -q" ] || q=1
66
77xdg_pid () {
88 local path=" ${XDG_DATA_HOME-} " /resh/daemon.pid
99 [ -n " ${XDG_DATA_HOME-} " ] && [ -f " $path " ] || return 1
1010 cat " $path "
11+ rm " $path "
1112}
1213default_pid () {
1314 local path=~ /.local/share/resh/daemon.pid
1415 [ -f " $path " ] || return 1
1516 cat " $path "
17+ rm " $path "
1618}
17- legacy_pid () {
18- local path=~ /.resh/resh.pid
19- [ -f " $path " ] || return 1
20- cat " $path "
21- }
22- pid=$( xdg_pid || default_pid || legacy_pid)
2319
24- if [ -n " $pid " ]; then
25- [ " ${1-} " != " -q" ] && printf " Stopping RESH daemon ... (PID: %s)\n" " $pid "
26- kill " $pid " || failed_to_kill
27- else
28- [ " ${1-} " != " -q" ] && printf " Stopping RESH daemon ...\n"
29- killall -q resh-daemon || failed_to_kill
30- fi
20+ kill_by_pid () {
21+ [ -n " $1 " ] || return 1
22+ [ " $q " = " 1" ] || printf " Stopping RESH daemon ... (PID: %s)\n" " $1 "
23+ kill " $1 "
24+ }
25+ kill_by_name () {
26+ [ " $q " = " 1" ] || printf " Stopping RESH daemon ...\n"
27+ killall -q resh-daemon
28+ }
29+ failed_to_kill () {
30+ [ " $q " = " 1" ] || echo " Failed to kill the RESH daemon - it probably isn't running"
31+ return 1
32+ }
3133
34+ kill_by_pid " $( xdg_pid) " || kill_by_pid " $( default_pid) " || kill_by_name || failed_to_kill
You can’t perform that action at this time.
0 commit comments