aboutsummaryrefslogtreecommitdiff
path: root/gitstatus/gitstatus.plugin.sh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-05-13 10:40:53 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-05-13 10:40:53 +0300
commite7f0bac67dce18032f44f3835ccd5b98b9ffcc73 (patch)
tree28b3523db7f4988cccc373c9d26f6b9ac7b0fc9c /gitstatus/gitstatus.plugin.sh
parent71f5f42997526e9301e42fe673b5dd07dc6e7472 (diff)
parenta6009c74a92f1c01d725364635aa38eba67bc15a (diff)
Merge commit 'a6009c74a92f1c01d725364635aa38eba67bc15a'
Diffstat (limited to 'gitstatus/gitstatus.plugin.sh')
-rw-r--r--gitstatus/gitstatus.plugin.sh27
1 files changed, 15 insertions, 12 deletions
diff --git a/gitstatus/gitstatus.plugin.sh b/gitstatus/gitstatus.plugin.sh
index c05f6cca..4c9b70f0 100644
--- a/gitstatus/gitstatus.plugin.sh
+++ b/gitstatus/gitstatus.plugin.sh
@@ -69,7 +69,7 @@ function gitstatus_start() {
local gitstatus_plugin_dir="$PWD"
fi
- local req_fifo resp_fifo
+ local tmpdir req_fifo resp_fifo
function gitstatus_start_impl() {
local log_level="${GITSTATUS_LOG_LEVEL:-}"
@@ -104,20 +104,22 @@ function gitstatus_start() {
--dirty-max-index-size="$max_dirty"
$extra_flags)
+ tmpdir="$(mktemp -d "${TMPDIR:-/tmp}"/gitstatus.bash.$$.XXXXXXXXXX)" || return
+
if [[ -n "$log_level" ]]; then
- GITSTATUS_DAEMON_LOG=$(mktemp "${TMPDIR:-/tmp}"/gitstatus.$$.log.XXXXXXXXXX) || return
+ GITSTATUS_DAEMON_LOG="$tmpdir"/daemon.log
[[ "$log_level" == INFO ]] || daemon_args+=(--log-level="$log_level")
else
GITSTATUS_DAEMON_LOG=/dev/null
fi
- req_fifo=$(mktemp -u "${TMPDIR:-/tmp}"/gitstatus.$$.pipe.req.XXXXXXXXXX) || return
- resp_fifo=$(mktemp -u "${TMPDIR:-/tmp}"/gitstatus.$$.pipe.resp.XXXXXXXXXX) || return
- mkfifo "$req_fifo" "$resp_fifo" || return
+ req_fifo="$tmpdir"/req.fifo
+ resp_fifo="$tmpdir"/resp.fifo
+ mkfifo -- "$req_fifo" "$resp_fifo" || return
{
(
- trap '' INT
+ trap '' INT QUIT TSTP
[[ "$GITSTATUS_DAEMON_LOG" == /dev/null ]] || set -x
builtin cd /
@@ -142,7 +144,7 @@ function gitstatus_start() {
[[ -n "$_gitstatus_bash_version" ]] || return
[[ "$_gitstatus_bash_downloaded" == [01] ]] || return
- local sig=(QUIT TERM EXIT ILL PIPE)
+ local sig=(TERM ILL PIPE)
if [[ -x "$_gitstatus_bash_daemon" ]]; then
"$_gitstatus_bash_daemon" \
@@ -166,7 +168,7 @@ function gitstatus_start() {
_gitstatus_bash_daemon=
_gitstatus_bash_version=
_gitstatus_bash_downloaded=
- source "$gitstatus_plugin_dir"/install || return
+ source "$gitstatus_plugin_dir"/install || return
[[ -n "$_gitstatus_bash_daemon" ]] || return
[[ -n "$_gitstatus_bash_version" ]] || return
[[ "$_gitstatus_bash_downloaded" == 1 ]] || return
@@ -180,13 +182,14 @@ function gitstatus_start() {
echo -nE $'bye\x1f0\x1e' >&"$fd_out"
) & disown
) & disown
- } 0</dev/null &>$GITSTATUS_DAEMON_LOG
+ } 0</dev/null &>"$GITSTATUS_DAEMON_LOG"
- exec {_GITSTATUS_REQ_FD}>"$req_fifo" {_GITSTATUS_RESP_FD}<"$resp_fifo" || return
- command rm "$req_fifo" "$resp_fifo" || return
+ exec {_GITSTATUS_REQ_FD}>"$req_fifo" {_GITSTATUS_RESP_FD}<"$resp_fifo" || return
+ command rm -f -- "$req_fifo" "$resp_fifo" || return
+ [[ "$GITSTATUS_DAEMON_LOG" != /dev/null ]] || command rmdir -- "$tmpdir" 2>/dev/null
IFS='' read -r -u $_GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID || return
- [[ $GITSTATUS_DAEMON_PID == [1-9]* ]] || return
+ [[ "$GITSTATUS_DAEMON_PID" == [1-9]* ]] || return
local reply
echo -nE $'hello\x1f\x1e' >&$_GITSTATUS_REQ_FD || return