bug-bash
[Top][All Lists]
Advanced

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

Re: Sourcing a script from a pipe is not reliable


From: Chet Ramey
Subject: Re: Sourcing a script from a pipe is not reliable
Date: Thu, 10 Jan 2019 18:55:10 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.3.3

On 1/10/19 4:52 PM, Jeremy wrote:

>     Have you considered reading stdin into a string (if it's one line) or an
>     array (if it's more) and using `eval' on it? That obviously works better
>     if it's one line, but could be made to work on multiple lines.
> 
> 
> We are trying to determine if the current shell supports passing positional
> arguments to a script sourced by dot (.), and we are trying to do it in a
> way that will work under pretty much any shell.

Bash does, but it's not portable.

> If you can show me how to
> do that with eval, then that would be great, even though in general I hate
> to ship a script that uses eval.

You have to do it yourself the old-fashioned way, using `set', if you want
to restrict yourself to using `eval'.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/



reply via email to

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