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: Robert Elz
Subject: Re: Sourcing a script from a pipe is not reliable
Date: Fri, 11 Jan 2019 05:36:17 +0700

    Date:        Thu, 10 Jan 2019 13:52:59 -0800
    From:        Jeremy <address@hidden>
    Message-ID:  <address@hidden>

  | 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.

The only real way to do that is to actually write such a script, and test it.
If you cannot write the script, you're basically out of luck, tricks with
/dev/stdin are not the way forward.

But the real question is why?

If you're prepared for a "no" answer, then why not simply assume the answer
is always going to be "no" for all shells ?

If you really need "." scripts with args, you could use

rundot()
{
        __F="$1"
        shift
        . "$__F"
}

or something similar (probably with some error checking) to
simulate processing a "." script with args.   The extra cost of
calling that function

        rundot script arg1 arg2 ...

rather than just

        . script arg1 arg2

isn't worth worrying about, the cost of the search for script,
and opening it, etc, dwarfs everything else that would be
happening, and that is the same both ways.

kre




reply via email to

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