On Wednesday, April 18, 2012 4:36:36 PM UTC+2, Chet Ramey wrote:
> On 4/18/12 9:18 AM, Victor Engmark wrote:
> > (Re-posted from Stack Overflow <http://unix.stackexchange.com/questions/36751/why-are-parameters-to-bashs-builtin-optional>)
> > Running simply `builtin` prints nothing and returns exit code 0. This is in accordance with `help builtin`, which shows all parameters as optional. But why isn't this no-op an error? Is there a use case for this? A more useful result would be an error code or, even better, listing the currently available builtins.
> What's the use case for having it be an error?
Since it's a nonsensical command, and since developers who haven't learned proper quoting shouldn't be shot too hard in the foot when they run `builtin $empty`. Or maybe they should be - Quoting is such a different matter from mainstream languages (and *much* more complex) that maybe `builtin` should print simply "Use More Quotes!" Seriously though, Bash is difficult enough as it is, and a spoonful of language fussiness is worth a ton of guard code.
> I can see printing a list of builtins, though `enable' already does that.
I guess the difference would be that `builtin` prints *all* builtins, and *never* modifies their state.