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
signature.asc Description: OpenPGP digital signature