help-bash
[Top][All Lists]
Advanced

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

Re: How to know < is specified for a script?


From: Eli Schwartz
Subject: Re: How to know < is specified for a script?
Date: Sun, 8 Mar 2020 16:25:35 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 3/8/20 2:12 PM, Peng Yu wrote:
> Hi,
> 
> Given the following two ways to call script.sh, is there a way in
> script.sh to tell how it is called? Thanks.
> 
> ./script.sh
> ./script.sh < something

In both cases it is called as ./script.sh, the only difference that is
caused by "< inputfile" is that the script is called with standard input
being redirected from a file rather than being a tty.

You could check [[ -t 0 ]] to see whether it is the first case.

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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