From c8160f29543a2f57ae7149103deefa029fd4e861 Mon Sep 17 00:00:00 2001 From: Roman Perepelitsa Date: Tue, 4 Jan 2022 12:14:19 +0100 Subject: [PATCH] Squashed 'gitstatus/' changes from f1cf61b24..e02d9eedd e02d9eedd fix cwd detection when it has weird characters 78c171590 Loongarch support (#290) be6396b1a fix pkg_add command on openbsd (#282) f1c89585a avoid ksh if possible (it's broken; see #282) 22407d6fd bug fix: correctly resolve pwd when it contains control chars git-subtree-dir: gitstatus git-subtree-split: e02d9eedd9d8f3689e6a6cdccec70b55cf87dca6 --- build | 16 +++++++++++++++- gitstatus.plugin.zsh | 16 ++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/build b/build index d23f8fc1..ad39910a 100755 --- a/build +++ b/build @@ -12,11 +12,24 @@ fi export LC_ALL=C if [ -z "${ZSH_VERSION-}" ] && command -v zsh >/dev/null 2>&1; then + # Avoid bash 3.*. case "${BASH_VERSION-}" in [0-3].*) exec zsh "$0" "$@";; esac fi +# Avoid ksh: https://github.com/romkatv/gitstatus/issues/282. +if [ -n "${KSH_VERSION-}" ]; then + if [ -z "${ZSH_VERSION-}" ] && command -v zsh >/dev/null 2>&1; then + exec zsh "$0" "$@" + elif [ -z "${BASH_VERSION-}" ] && command -v bash >/dev/null 2>&1 && + bash_version="$(bash --version 2>&1)"; then + case "$bash_version" in + *version\ [4-9]*|*version\ [1-9][0-9]*) exec bash "$0" "$@";; + esac + fi +fi + usage="$(command cat <<\END Usage: build [-m ARCH] [-c CPU] [-d CMD] [-i IMAGE] [-s] [-w] @@ -91,7 +104,7 @@ if [ -n "$gitstatus_install_tools" ]; then command pkg install -y cmake gmake binutils git perl5 wget ;; openbsd) - command pkg_add install cmake gmake gcc git wget + command pkg_add cmake gmake gcc g++ git wget ;; netbsd) command pkgin -y install cmake gmake binutils git @@ -509,6 +522,7 @@ if [ -z "$gitstatus_cpu" ]; then arm64|aarch64) gitstatus_cpu=armv8-a;; ppc64le) gitstatus_cpu=powerpc64le;; riscv64) gitstatus_cpu=rv64imafdc;; + loongarch64) gitstatus_cpu=loongarch64;; x86_64|amd64) gitstatus_cpu=x86-64;; x86) gitstatus_cpu=i586;; s390x) gitstatus_cpu=z900;; diff --git a/gitstatus.plugin.zsh b/gitstatus.plugin.zsh index cef78974..181e756a 100644 --- a/gitstatus.plugin.zsh +++ b/gitstatus.plugin.zsh @@ -185,9 +185,21 @@ function gitstatus_query"${1:-}"() { (( _GITSTATUS_STATE_$name == 2 )) || return if [[ -z $GIT_DIR ]]; then - [[ $dir == /* ]] || dir=${(%):-%/}/$dir + if [[ $dir != /* ]]; then + if [[ $PWD == /* && $PWD -ef . ]]; then + dir=$PWD/$dir + else + dir=${dir:a} + fi + fi else - [[ $GIT_DIR == /* ]] && dir=:$GIT_DIR || dir=:${(%):-%/}/$GIT_DIR + if [[ $GIT_DIR == /* ]]; then + dir=:$GIT_DIR + elif [[ $PWD == /* && $PWD -ef . ]]; then + dir=:$PWD/$GIT_DIR + else + dir=:${GIT_DIR:a} + fi fi if [[ $dir != (|:)/* ]]; then