Say I have the function shoutout inside my .profile file.
When I run shoutout 'Hello', the function prints out Hello, which is the expected response. However, I’d like to be able to simply call shoutout with no parameters and have the function print out Foobar.
How do I specify a default value for $1 with or without variables? Thanks!
shoutout() {
echo $1
}
EDIT: Thanks to @ephemient for this extra tid-bit that I wasn’t aware of…
To avoid confusing an empty-string argument as a missing argument, omit the colon (
:):