I found this line in one of our repositories without any comments explaining what it does. I am fixing a bug that I found in this repository and don't know what to make of this line. I am unsure of how to research for this in a time efficient manner, so I'm asking here.
[ "$foo_user" = 'foo' ] && foo_user='bar' || true
It looks like an if statement that tests if $foo_user='foo' then return true, and then sets foo_user to "bar" if it is not set? I really have no idea what to make of this.
What does this code do?
set -ewould not matter as this is and/or list. However, it would matter in a Makefile, for example, or in any other setting where the exit status of individual pipelines/commands matter. – Kusalananda May 07 '21 at 15:22|| trueis necessary in such circumstances ;-). – Stephen Kitt May 07 '21 at 15:32