aboutsummaryrefslogtreecommitdiff
path: root/gitstatus
diff options
context:
space:
mode:
authorRoman Perepelitsa <roman.perepelitsa@gmail.com>2021-11-02 09:23:57 +0300
committerRoman Perepelitsa <roman.perepelitsa@gmail.com>2021-11-02 09:23:57 +0300
commitd281e595b3ddf2f5ccefb0cd7bfa475222566186 (patch)
tree42638fe0cb9652e5d8f12b084f6c66701bf8028f /gitstatus
parenta55955c5cfb360c6088fd0141c6157533f3e1481 (diff)
parente2447322e0be4eddb84196f05952f91fa3c6f37e (diff)
Merge commit 'e2447322e0be4eddb84196f05952f91fa3c6f37e'
Diffstat (limited to 'gitstatus')
-rw-r--r--gitstatus/gitstatus.plugin.sh7
-rwxr-xr-xgitstatus/install44
2 files changed, 26 insertions, 25 deletions
diff --git a/gitstatus/gitstatus.plugin.sh b/gitstatus/gitstatus.plugin.sh
index 9a75cb5f..0c660967 100644
--- a/gitstatus/gitstatus.plugin.sh
+++ b/gitstatus/gitstatus.plugin.sh
@@ -53,9 +53,8 @@ function gitstatus_start() {
fi
unset OPTIND
- local opt timeout=5 max_dirty=-1 ttl=3600 extra_flags
+ local opt timeout=5 max_dirty=-1 ttl=3600 extra_flags=
local max_num_staged=1 max_num_unstaged=1 max_num_conflicted=1 max_num_untracked=1
- local ignore_status_show_untracked_files
while getopts "t:s:u:c:d:m:r:eUWD" opt; do
case "$opt" in
t) timeout=$OPTARG;;
@@ -356,7 +355,7 @@ function gitstatus_stop() {
# shell or the call had failed.
function gitstatus_query() {
unset OPTIND
- local opt dir timeout=() no_diff=0
+ local opt dir= timeout=() no_diff=0
while getopts "d:c:t:p" opt "$@"; do
case "$opt" in
d) dir=$OPTARG;;
@@ -367,7 +366,7 @@ function gitstatus_query() {
done
(( OPTIND == $# + 1 )) || { echo "usage: gitstatus_query [OPTION]..." >&2; return 1; }
- [[ -n "$GITSTATUS_DAEMON_PID" ]] || return # not started
+ [[ -n "${GITSTATUS_DAEMON_PID-}" ]] || return # not started
local req_id="$RANDOM.$RANDOM.$RANDOM.$RANDOM"
if [[ -z "${GIT_DIR:-}" ]]; then
diff --git a/gitstatus/install b/gitstatus/install
index 981d280a..a0142b2b 100755
--- a/gitstatus/install
+++ b/gitstatus/install
@@ -304,27 +304,29 @@ END
local data_file="$tmpdir"/"$1".tar.gz
local hash_file="$tmpdir"/"$1".tar.gz.sha256
local hash=
- if command -v shasum >/dev/null 2>/dev/null; then
- if run_cmd shasum -b -a 256 -- "$data_file" >"$hash_file"; then
- IFS= read -r hash <"$hash_file" || hash=
- hash="${hash%% *}"
- fi
- elif command -v sha256sum >/dev/null 2>/dev/null; then
- if run_cmd sha256sum -b -- "$data_file" >"$hash_file"; then
- IFS= read -r hash <"$hash_file" || hash=
- hash="${hash%% *}"
- fi
- elif command -v sha256 >/dev/null 2>/dev/null; then
- if run_cmd sha256 -- "$data_file" </dev/null >"$hash_file"; then
- IFS= read -r hash <"$hash_file" || hash=
- # Ignore sha256 output if it's from hashalot. It's incompatible.
- if [ ${#hash} -lt 64 ]; then
- hash=
- else
- hash="${hash##* }"
- fi
- fi
- fi
+ {
+ command -v shasum >/dev/null 2>/dev/null &&
+ run_cmd shasum -b -a 256 -- "$data_file" >"$hash_file" </dev/null &&
+ IFS= read -r hash <"$hash_file" &&
+ hash="${hash%% *}" &&
+ [ ${#hash} -eq 64 ]
+ } || {
+ command -v sha256sum >/dev/null 2>/dev/null &&
+ run_cmd sha256sum -b -- "$data_file" >"$hash_file" </dev/null &&
+ IFS= read -r hash <"$hash_file" &&
+ hash="${hash%% *}" &&
+ [ ${#hash} -eq 64 ]
+ } || {
+ # Note: sha256 can be from hashalot. It's incompatible.
+ # Thankfully, it produces shorter output.
+ command -v sha256 >/dev/null 2>/dev/null &&
+ run_cmd sha256 -- "$data_file" >"$hash_file" </dev/null &&
+ IFS= read -r hash <"$hash_file" &&
+ hash="${hash##* }" &&
+ [ ${#hash} -eq 64 ]
+ } || {
+ hash=
+ }
[ "$1" = 1 -a -z "$hash" -o "$hash" = "$sha256" ]
}