bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add new program: magic


From: Bo Borgerson
Subject: Re: [PATCH] Add new program: magic
Date: Thu, 10 Apr 2008 09:10:29 -0400

On Wed, Apr 9, 2008 at 9:48 PM, Bob Proulx <address@hidden> wrote:
>  I like this sort of general purpose utility that can work with a broad
>  set of things much better than hacks to every utility.  It is
>  definitely a better direction.
>
>  But I don't like the name.  The name is too generic and doesn't give a
>  clue as to what it actually does.  This is probably better to name
>  something like daylight-commander or some such (with apologies to
>  Nortan and midnight-commander).

Point taken :)

I knew I would need to change the name.  I should have done so before
submitting the draft.  Do you have any suggestions for a more
descriptive name?  How about 'fargs', as a contraction of fifo-args?
I'll use that at least for the duration of this message.

>  Additionally I have to note that bash (and probably other shells)
>  already supply this capability in a generic way.
>
>   sort <(zcat a) <(zcat b) c

Yeah, bash is great!

There are some differences, though:

$ fargs wc input/*
    314    1895   12183 /tmp/fargsBsoaWi/HACKING.gz
    560    1796   31786 /tmp/fargsBsoaWi/THANKS.bz2
    177     976    6908 input/TODO
   1051    4667   50877 total

$ wc <(zcat input/HACKING.gz) <(bzcat input/THANKS.bz2) input/TODO
    314    1895   12183 /dev/fd/63
    560    1796   31786 /dev/fd/62
    177     976    6908 input/TODO
   1051    4667   50877 total

First, with the bash syntax you need to enumerate the set of commands
you want to run.  Second, for programs that use filenames in output or
diagnostic messages, the fifos produced by fargs may be somewhat more
legible.

Also, so far as I know there isn't any way currently to use
--files0-from=F style argument passing, as with `wc' (and pending in
`sort').  There may be a trick here that I just haven't learned yet,
but I'd like to be able to do the following (more so with `sort', but
I'll use `wc' for illustration).

$ find input/ -type f --files0 | fargs wc --files0-from=-
    177     976    6908 input/TODO
    314    1895   12183 /tmp/fargsLywSy2/HACKING.gz
    560    1796   31786 /tmp/fargsLywSy2/THANKS.bz2
   1051    4667   50877 total

>  This is getting to be too heuristic driven (too error prone) for my
>  tastes.

The precedence is `directive>option>file>command'.  There are some
cases where the interpretation may be surprising.

If you have a file in your current working directory named 'ls' and
you intend to use 'ls' as a sub-command, then:

$ fargs wc ls

Won't give you what you want.  For this reason I included the 'exec:' directive:

$ fargs wc exec:ls

If you manage to produce a compressed file named '-l' and you run:

$ fargs wc -l

You could be waiting for a long time.  For this reason I included the
'file:' directive:

$ fargs wc file:-l

Finally, because `fargs' doesn't know which options of the invoked
command take arguments, if you run:

$ fargs sort -o output input/*

and `output' already exists, you may be in for a surprise.  For this
reason I included the 'skip:' directive:

$ fargs sort -o skip:output input/*

Of course this last case could be avoided by using the long-option form:

$ fargs sort --output=output input/*

Note that regardless of whether arbitrary sub-commands are allowed,
this last case is an issue.

>   diff <(ssh -n host1 cat /etc/passwd) <(ssh -n host2 cat /etc/passwd)

That one really looked like a nail when I'd just finished building my
shiny new hammer. ;)

Thanks,

Bo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]