Am I not seeing the Error?

Chris Angelico rosuav at gmail.com
Wed Aug 14 08:07:38 EDT 2013


On Wed, Aug 14, 2013 at 7:59 AM, Joshua Landau <joshua at landau.ws> wrote:
> On 14 August 2013 02:20, Gregory Ewing <greg.ewing at canterbury.ac.nz> wrote:
>> Ned Batchelder wrote:
>>>
>>> Everyone: this program seems to be a direct and misguided transliteration
>>> from a bash script.
>>
>> Not a particularly well-written bash script, either --
>> it's full of superfluous uses of 'cat'.
>
> What's wrong with cat? Sure it's superfluous but what makes it *bad*?
> Personally I often prefer the pipe "cat x | y" form to "x < y"... or
> "< y x".

What's the use of it, in that situation? Why not simply use
redirection? (Though you have the letters backward; "cat y | x" would
be the equivalent of your others. Typo, I assume.) You're forking a
process that achieves nothing, if your cat has just one argument.

Of course, there ARE many good uses for cat. If you give it multiple
arguments, or if you have arguments that modify the output on the way
through (eg "cat -n"), then it's not the same as redirection. And some
programs behave differently if stdout is a tty, so the quickest way to
get the porcelain version of something is to append "|cat" to the
command. Or maybe you need to retrieve something that only root can
read, so you use "sudo cat /x/y/z|somescript". But if you could spell
it "x < y", then why not do so?

ChrisA



More information about the Python-list mailing list