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