I would like to make a string that includes an argument:
function praise () {
echo "{$1} is great"
}
However when I run praise BillyBob
I get is great BillyBob
. What am I doing wrong?
I would like to make a string that includes an argument:
function praise () {
echo "{$1} is great"
}
However when I run praise BillyBob
I get is great BillyBob
. What am I doing wrong?
I figured out the problem. The function was in my .bash_profile
. When I source
this file, bash doesn't update the praise function with whatever version is in the file, although aliases and variables like PS1 are updated. I don't know why praise isn't updated, but opening a fresh bash instance resolves the problem. The terminal tab I was testing in must have had an outdated version of this function that was causing the error (maybe a newline issue, but hard to say at this point). My code works as expected in a new tab.