Re: Suggested dual human/binary interface for proc/devfs

From: Ed Carp (erc@pobox.com)
Date: Tue Apr 11 2000 - 03:56:37 EST


George Bonser (grep@shorelink.com) writes:

> On Tue, 11 Apr 2000, Ed Carp wrote:
>
> > Uh, I would've thought that would've been intuitively obvious ;)
> >
> > device=eth0;ip_address=192.168.201.116,netmask=255.255.255.0
> > device=eth1;ip_address=192.168.201.117,netmask=255.255.255.0
>
> So you have made it more difficult.

Not at all.

> I can not understand what makes yours easier. Look at it a different way:
>
> device
> eth0;ip_address=192.168.201.116,netmask=255.255.255.0
> eth1;ip_address=192.168.201.117,netmask=255.255.255.0
>
> Now you have exactly the same thing as I wrote only:
>
> you have a newline instead of a { after device
> you a , instead of a ;(or newline) between attribute/data pairs
> you use ;...<newline> instead of {} between groups

And so it becomes much easier to parse, and much easier to visually understand, instead of a bunch of stuff indented with braces running down a page. Even easier would be:

eth0 192.168.201.116 255.255.255.0
eth1 192.168.201.117 255.255.255.0

What could be simpler than

DEVICE=eth1
IPADDR=`grep ^$DEVICE\; file|cut -d' ' -f2`

> Imagine you are doing a .dump file for /proc/sys/net that outputs
> EVERYTHING below it in the tree. How do you present the output so it is
> easy to parse? Think about arrays.

I think I just did. George, stop thinking about this as some sort of problem that requires complicated parsers and lisp-like structures - it doesn't. It's very easy if you think about it in terms of "easy to parse" for a shell script. Your lisp-looking stuff is more difficult to parse in a shell script, and I'd hate to insist that Linus incorporate that sort of thing into the kernel - the most polite thing he'd probably do is laugh.

> As for code that already parses this format, think about any util that
> operates on bind or gated configuration files.

That sort of code is horrible to implement in a shell script. Where do you have it implemented in one?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:15 EST