[ILUG] Re: [techtalk] How a script is called

Fergal Daly fergal at esatclear.ie
Thu Aug 17 01:24:25 EST 2000


At 19:48 16/08/00, Conor Daly wrote:
>On Wed, Aug 16, 2000 at 08:15:13AM +0100 or so it is rumoured hereabouts,
>  Conor Daly thought...
> > Anyone know how a bash / csh script can tell if it was called in a 
> pipeline or
> > directly from the commandline?  I've a script that I want to run either by
> > catting a file through a pipe or by invoking from the commandline with the
> > file as an arg and I need the script to behave slightly differently in 
> either
> > case.
> >
>
>Nice answers everyone but, alas, there is an implicit assumption that there's
>only one arg or none involved.  I'm accepting up to three args in any order at
>present and have no control over how the script is called in the case of a
>pipe.

Not trying to start (another ;-) fight but did you read my reply? Using if 
[ -t 0 ] makes no assumptions about arguments, it is a common and standard 
way of checking whether you're being piped or not. You can find it in no 
less an authority than the Perl Cookbook and I'm sure many other places,

Fergal







More information about the Techtalk mailing list