1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-14 00:50:08 +00:00

Squashed 'gitstatus/' changes from eaf430112..e26996460

e26996460 survive broken shasum
b1825b29a make bash bindings work with nounset

git-subtree-dir: gitstatus
git-subtree-split: e269964607042ef0fdbda2d7af74ef9c8f618cf4
This commit is contained in:
Roman Perepelitsa 2021-11-02 07:23:57 +01:00
parent 1af6385436
commit e2447322e0
2 changed files with 26 additions and 25 deletions

View file

@ -53,9 +53,8 @@ function gitstatus_start() {
fi fi
unset OPTIND 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 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 while getopts "t:s:u:c:d:m:r:eUWD" opt; do
case "$opt" in case "$opt" in
t) timeout=$OPTARG;; t) timeout=$OPTARG;;
@ -356,7 +355,7 @@ function gitstatus_stop() {
# shell or the call had failed. # shell or the call had failed.
function gitstatus_query() { function gitstatus_query() {
unset OPTIND unset OPTIND
local opt dir timeout=() no_diff=0 local opt dir= timeout=() no_diff=0
while getopts "d:c:t:p" opt "$@"; do while getopts "d:c:t:p" opt "$@"; do
case "$opt" in case "$opt" in
d) dir=$OPTARG;; d) dir=$OPTARG;;
@ -367,7 +366,7 @@ function gitstatus_query() {
done done
(( OPTIND == $# + 1 )) || { echo "usage: gitstatus_query [OPTION]..." >&2; return 1; } (( 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" local req_id="$RANDOM.$RANDOM.$RANDOM.$RANDOM"
if [[ -z "${GIT_DIR:-}" ]]; then if [[ -z "${GIT_DIR:-}" ]]; then

42
install
View file

@ -304,27 +304,29 @@ END
local data_file="$tmpdir"/"$1".tar.gz local data_file="$tmpdir"/"$1".tar.gz
local hash_file="$tmpdir"/"$1".tar.gz.sha256 local hash_file="$tmpdir"/"$1".tar.gz.sha256
local hash= local hash=
if command -v shasum >/dev/null 2>/dev/null; then {
if run_cmd shasum -b -a 256 -- "$data_file" >"$hash_file"; then command -v shasum >/dev/null 2>/dev/null &&
IFS= read -r hash <"$hash_file" || hash= run_cmd shasum -b -a 256 -- "$data_file" >"$hash_file" </dev/null &&
hash="${hash%% *}" IFS= read -r hash <"$hash_file" &&
fi hash="${hash%% *}" &&
elif command -v sha256sum >/dev/null 2>/dev/null; then [ ${#hash} -eq 64 ]
if run_cmd sha256sum -b -- "$data_file" >"$hash_file"; then } || {
IFS= read -r hash <"$hash_file" || hash= command -v sha256sum >/dev/null 2>/dev/null &&
hash="${hash%% *}" run_cmd sha256sum -b -- "$data_file" >"$hash_file" </dev/null &&
fi IFS= read -r hash <"$hash_file" &&
elif command -v sha256 >/dev/null 2>/dev/null; then hash="${hash%% *}" &&
if run_cmd sha256 -- "$data_file" </dev/null >"$hash_file"; then [ ${#hash} -eq 64 ]
IFS= read -r hash <"$hash_file" || hash= } || {
# Ignore sha256 output if it's from hashalot. It's incompatible. # Note: sha256 can be from hashalot. It's incompatible.
if [ ${#hash} -lt 64 ]; then # 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= hash=
else }
hash="${hash##* }"
fi
fi
fi
[ "$1" = 1 -a -z "$hash" -o "$hash" = "$sha256" ] [ "$1" = 1 -a -z "$hash" -o "$hash" = "$sha256" ]
} }