Randall R Schulz wrote:
On Monday 29 October 2007 14:33, Thomas Hertweck wrote:
Randall R Schulz wrote:
[...]

I use this shell procedure (defined in my .bashrc) to query local
variables:

vq () {
    set | egrep -e "$1"
}
Isn't "set" also reporting functions etc.? I usually use "printenv"
to query (environment) variables...

That's true (though I don't think there's anything left in the "etc." category besides local variables and function definitions), so if I query a name found in a function definition, I'll get spurious results. But it's usually pretty easy to spot and ignore them.

But the point of "vq" (value query) vs. "eq" (environment query) is to be able to distinguish the two. The second function I gave is restricted to exported variables (which by definition excludes shell functions).

And printenv is a standard command, thus requiring a(nother) fork / exec to invoke. Export doesn't, so it has lower overhead. It's of little real consequence, but some of us are still efficiency freaks...

But then you have to fork off the sed or grep command, and then
do write(2) into and read(2) out of the pipe, so I'm not seeing
any increased efficiency there when compared to env or printenv.

Could it be that this was a hack from the late 70's early 80's
that you've just become used to doing, and never re-evaluated
whether it is still necessary (or even most efficient)?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to