Why doesn't autoconf like our /bin/sh?

John Baldwin jhb at freebsd.org
Thu May 29 04:30:56 UTC 2008


On Sunday 25 May 2008 11:45:37 am Stefan Farfeleder wrote:
> On Sun, May 25, 2008 at 09:06:47AM -0600, John E Hein wrote:
> > FWIW, it seems bash and sh report line number differently.
> >
> > # grep -n ^ ~/tmp/ln
> > 1:#!/bin/sh
> > 2:echo f line: $LINENO
> > 3:f()
> > 4:{
> > 5:echo f line: $LINENO
> > 6:}
> > 7:
> > 8:f
> > 9:echo main line: $LINENO
> > 10:f
> >
> >
> > # /bin/sh ~/tmp/ln
> > f line: 2
> > f line: 3
> > main line: 9
> > f line: 3
> >
> >
> > # bash ~/tmp/ln
> > f line: 2
> > f line: 5
> > main line: 9
> > f line: 5
>
> Yes, I know.  I think it is a bug in bash as SUSv3 states:
>
> "Set by the shell to a decimal number representing the current
> sequential line number (numbered starting with 1) within a script or
> function before it executes each command."

Actually, the bash way seems more intuitive.  And it does say "the current 
sequentional line number within a ... function before it executes each 
command"

The "within a function" implies that this property goes inside of functions 
instead of forcing all commands in a function to use the starting line of the 
function which is what you are saying?

-- 
John Baldwin


More information about the freebsd-hackers mailing list