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.
pull/1840/head
terminalforlife 2021-02-17 21:42:24 +00:00
parent 12e225afef
commit f4299f437c
1 changed files with 1 additions and 1 deletions

View File

@ -193,7 +193,7 @@ function git_prompt_minimal_info {
SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX}\$(_git-friendly-ref)" 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_DIRTY=1
SCM_STATE=${SCM_THEME_PROMPT_DIRTY} SCM_STATE=${SCM_THEME_PROMPT_DIRTY}
fi fi