I have a variable that may or may not be empty. If it's not empty, I want that value. If it is empty, I want the value of some other command. Example:
my_function ()
{
name_override="$1"
user_name=${name_override} || $(git config "user.name")
}
I'm not sure if the code above will work. But basically I want to run git config
and store that result in user_name
if the name_override
variable is unset (and thus $1
would not have been provided).
How can I do this correctly?