1 |
Am Tue, Dec 07, 2021 at 10:26:11AM -0700 schrieb Grant Taylor: |
2 |
> Some drive-by after-the-fact comments: |
3 |
> |
4 |
> On 12/6/21 4:03 PM, Frank Steinmetzger wrote: |
5 |
> > [ "$MC_SID" ] && PS1_JOBS_COUNT="${PS1_JOBS_COUNT}MC " |
6 |
> > [ "$RANGER_LEVEL" ] && PS1_JOBS_COUNT="${PS1_JOBS_COUNT}R " |
7 |
> |
8 |
> I've taken to using things like the following: |
9 |
> |
10 |
> PS1_JOBS_COUNT="${PS1_JOBS_COUNT}${MC_SID:+MC }${RANGER_LEVEL:+R }" |
11 |
> |
12 |
> Leverage Bash's (and Zsh's) expansion conditional. If the variable is set, |
13 |
> then expand it to a different value. |
14 |
|
15 |
By jove, you’re right. Maybe I’ve written that stuff before I knew about |
16 |
default values. I checked in that code in September of 2016. And it could |
17 |
possibly be even much older, because I clean up my config git repository |
18 |
only very sporadically, as in two or three times a year. |
19 |
|
20 |
> ${VARIABLE:+alternate text to show if VARIABLE is set} |
21 |
> |
22 |
> > if [[ -z "$PROMPT_COMMAND" ]]; then |
23 |
> > PROMPT_COMMAND=__jobsprompt |
24 |
> > else |
25 |
> > PROMPT_COMMAND="$PROMPT_COMMAND ; __jobsprompt" |
26 |
> > fi |
27 |
> |
28 |
> Is there a reason to not simply do the following, eliminating the if |
29 |
> conditional: |
30 |
> |
31 |
> PROMPT_COMMAND=${PROMPT_COMMAND:+${PROMPT_COMMAND} ; __jobsprompt} |
32 |
|
33 |
Maybe inexperience? :D |
34 |
Or sometimes, explicit is better than implicit? |
35 |
|
36 |
-- |
37 |
Grüße | Greetings | Qapla’ |
38 |
Please do not share anything from, with or about me on any social network. |
39 |
|
40 |
I had a problem and used Java. Now I have a ProblemFactory. |