From f4299f437c5bbfe626e6d0cf8f2c31a77340565a Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 17 Feb 2021 21:42:24 +0000 Subject: [PATCH] Remove redundant use of tail(1) In: ```bash if [[ -n "$(_git-status | tail -n1)" ]]; then ``` It seems pointless using tail(1); it does nothing here, unless I'm missing something. Also, quotes aren't needed, because word-splitting doesn't apply when variables are expanded in `[[`. ```bash if [[ -n $(_git-status) ]]; then ``` The quoting thing is all over the code, but not a huge deal, as it's just superficial. Variable word-splitting doesn't apply also during the WORD in the case statement, and the VALUE in shell variable assignment. Personally, I would use `[`, since none of the `[[` features are being used here, so it seems wasteful. In the BASH (4.4) source code, assuming I'm looking at it correctly, `[[` is over 800 lines, yet `[` (or `test`) is not even 200; that's part of the reason I prefer `[` and use `[[` when it's actually needed. It's also not a huge deal though, - as this is going to be incredibly fast either way, but thought I'd mention it. --- themes/base.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 64d5c888..b4798b9c 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -193,7 +193,7 @@ function git_prompt_minimal_info { SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX}\$(_git-friendly-ref)" - if [[ -n "$(_git-status | tail -n1)" ]]; then + if [[ -n $(_git-status) ]]; then SCM_DIRTY=1 SCM_STATE=${SCM_THEME_PROMPT_DIRTY} fi