[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash Coding style - Adopting C99 declarations
From: |
Greg Wooledge |
Subject: |
Re: Bash Coding style - Adopting C99 declarations |
Date: |
Sun, 28 Aug 2022 11:47:21 -0400 |
On Sun, Aug 28, 2022 at 10:47:38AM -0400, Yair Lenga wrote:
> Hi,
>
> I've noticed Bash code uses "old-style" C89 declarations:
> * Parameters are separated from the prototype
> * Variables declared only at the beginning of the function
> * No mixed declaration/statements
> * No block local variables
>
> intmax_t
> evalexp (expr, flags, validp)
> char *expr;
> int flags;
> int *validp;
> {
> intmax_t val;
> int c;
> procenv_t oevalbuf;
>
> val = 0;
> noeval = 0;
> already_expanded = (flags&EXP_EXPANDED);
You're mistaken. What you're seeing is the "K&R" coding style, which
predates C89.
I'm pretty sure that the decision to continue in this style well past
the widespread adoption of C89 was because of a desire to use bash on
systems that still had a K&R C compiler. A lot of the oldest GNU projects
followed this idea, in order to increase the number of commercial Unix
systems on which they could be used.