I inherited some bash scripts where the author used "-" in the function names instead of the more normal "_" e.g.:
function a-b {
...
}
Ugly but legal in bash. Problem is I sourced this inside an upstart script and got
x.sh: line 5: `a-b': not a valid identifier
Took a while to realize it was the name and not the function contents. Anyway, renaming is not an easy option in this case and as I've learned, upstart uses /bin/sh
not /bin/bash
to parse? run its scripts. Hence I guess this issue.
Any ideas on a workaround other than renaming?
If nothing else, at least I hope this question will warn others on the perils of odd bash coding styles and how they come back to bite you sometimes.