Search code examples
bashnaming

Exclamation point in bash function name - should I?


I'm writing a bash script and it's really convenient to use an exclamation point in a function name.

Example:

function hello! {
    echo goodbye
}
function hello {
    echo hello
}

And it works!

After looking through the specs, I found this:

name A word consisting solely of letters, numbers, and underscores, and beginning with a letter or underscore. Names are used as shell variable and function names. Also referred to as an identifier.

I feel like I'm breaking the rules here. Is this wrong? Will this mess something up in the future? What's actually going on?


Solution

  • Out of burning curiousity, why is it so much more convenient to use the exclamation point in your function name?

    Generally, for portability reasons, you may not want to use the bang; just because the interpreter on that particular OS accepts it, if you need to deploy that script elsewhere, other interpreters of slightly different flavors/versions may not be as accepting.