On 4/17/15 6:27 PM, Linda Walsh wrote: > > > Eduardo A. Bustamante López wrote: >> Well, if your scripts are so simple, why use local functions at all? > --- > Cleanliness, Hygiene...
Please, let's not have this argument again. I think you're all using the term `local function' to mean different things. You seem to be using the term to describe one-time-use functions (they're almost lambdas, but they have names). If you define a function within another function's body, have it unset itself when it executes, and call it only from within the function where it's defined, you have something very close to one-time-use functions with function-only scope. However you use them, they share the name namespace as every other defined function, regardless of whether or not they are defined as part of the body of another function. If you had a function defined in the global scope with the same name as your one-time-use function, it would be removed when the one-time-use function was declared. I think this is what Greg and Eduardo mean, and in this sense they are correct: bash doesn't have local functions with separate namespaces from other defined functions. That's the difference: if you're careful with naming and rigorous about your calling conventions, your one-time-use functions are about as close as you can get to local functions in bash, but you have to pay attention to the declaration's side effects. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/