From c2fcf35ab1a103065c0804b0bd9874f5052932eb Mon Sep 17 00:00:00 2001 From: Crestwave Date: Thu, 16 Apr 2020 09:52:25 +0800 Subject: [PATCH] neofetch: only fork for {BASH,OIL}_VERSION when necessary --- neofetch | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 4c12b86c..234a7907 100755 --- a/neofetch +++ b/neofetch @@ -33,7 +33,6 @@ version=7.0.0 if [[ "$BASH_VERSION" ]]; then bash_version=${BASH_VERSION/.*} else - BASH_VERSION=$(bash -c "printf %s \"\$BASH_VERSION\"") bash_version=5 shopt -s eval_unsafe_arith fi @@ -1590,7 +1589,11 @@ get_shell() { [[ $shell_version != on ]] && return case ${shell_name:=${SHELL##*/}} in - bash) shell+=${BASH_VERSION/-*} ;; + bash) + [[ $BASH_VERSION ]] || + BASH_VERSION=$("$SHELL" -c "printf %s \"\$BASH_VERSION\"") + shell+=${BASH_VERSION/-*} + ;; sh|ash|dash) ;; @@ -1601,7 +1604,11 @@ get_shell() { ;; osh) - shell+=$("$SHELL" -c "printf %s \"\$OIL_VERSION\"") + if [[ $OIL_VERSION ]]; then + shell+=$OIL_VERSION + else + shell+=$("$SHELL" -c "printf %s \"\$OIL_VERSION\"") + fi ;; tcsh)