Re: [dev] Shell vs C where is the border?

From: Paul Onyschuk <blink_AT_bojary.koba.pl>
Date: Mon, 10 Mar 2014 21:22:39 +0100

On Mon, 10 Mar 2014 20:39:08 +0100
Szymon Olewniczak <szymon.olewniczak_AT_rid.pl> wrote:

> But having so many individual programs is more harder to use that just
> one (we need to run more commands), so reasonable would be to combine
> all this commands to one script which would do all this work
> automaticaly. So what solution would be better in your opinion? When
> we should use shell scripts and when write new C programs to achieve
> our goals?

My mail probably will be bounced, but anyway.

It (pipes or lack of them) can be abused either way. Example of way too
many command line flags (GNU ls):

$ ls --help | awk '/^ {2,6}-/{i++} END{print i}'
58

Yet you won't likely use more than a dozen options offered by ls ever
(and fewest on daily basis). Those rare cases, when you need something
specialized could be solved by sed/awk and other filters. Still they
somehow managed to squeeze all those flags there - someone really hates
pipes.

Counter example would be man(1) command (this is personal opinion).
Some implementation are doing something similar to that:

$ zcat some-manpage.1.gz | eqn | grap | pic | tbl | vgrind | refer \
| troff | more

This is running every time when you type "man some-manpage". Filter
approach of *roff made sense, when it was used for creating documents
for printing (and it was often most CPU intensive command on the box
according to some accounts).

-- 
Paul Onyschuk
Received on Mon Mar 10 2014 - 21:22:39 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 10 2014 - 21:36:07 CET