help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Closure concept in bash


From: Greg Wooledge
Subject: Re: [Help-bash] Closure concept in bash
Date: Tue, 31 Jan 2012 11:08:20 -0500
User-agent: Mutt/1.4.2.3i

On Tue, Jan 31, 2012 at 09:38:45AM -0600, Peng Yu wrote:
> I don't know whether parallel uses 'bash' or 'sh'.

The man page does not say.  It doesn't say much of ANYTHING, to be
honest.

> But it seems that
> it understands bash function.

"It" does no such thing, if "it" is GNU parallel.  GNU parallel simply
executes a child process.

> Is bash function and sh function
> interchangeable?

In a word: no.

arc3:~$ foo() { echo I AM FOO; }
arc3:~$ export -f foo
arc3:~$ dash
\h:\w$ foo
dash: foo: not found
(ctrl-d)
arc3:~$ bash
arc3:~$ foo
I AM FOO

The dash child process did not understand how to retrieve the definition
of the function "foo" from the environment.  The bash child process did.
This is precisely what I mean when I say that exporting functions to
child processes is a feature that only works in bash.

The exported function definition will be carried along by every process
in the environment like a useless oversized suitcase, but only bash can
open it.

> > I have no idea what problem you are trying to solve.
> 
> Call gnu parallel in the most convenient way (meaning using the least
> amount of time to type the code, while make it readable and
> maintainable).

You appear to be what we call a "cultist" on the IRC channel.  You don't
have a specific goal in mind at all.  Rather, you have a technology (toy,
module, paradigm, tenet) that you want to use simply because it's shiny.

So, you keep dodging and weaving and changing the questions you ask,
hoping to stumble upon a question that will produce an answer that uses
your chosen technology.  When you finally get an answer that uses your
technology, you will be happy and you will go away.  If we cannot bend
over far enough backward or squint hard enough to interpret your questions
in such a way that they can be answered by your chosen technology, you
will be unhappy.  The "unhappy" case is what happens the vast majority of
the time, especially once we figure out what is actually occurring.

Bash is a shell.

A shell is a program that reads commands and executes them.

The commands that bash understands are documented in its manual, which
is comprehensive.

If there is a type of command that you want to use (a closure, for
example) and it is not in the manual, then bash does not know how to
do that.

If that type of command is ESSENTIAL to you, then you must use something
other than bash, because bash can't do it.  (This is the "cultist"
problem.)

If that type of command was just a TOOL you were trying to use to solve
a problem, then state the problem, and maybe we can suggest some OTHER
tool that would work.  (This is what I've been trying to do all week.  It
hasn't been working, which is what leads me to the "cultist" conclusion.)



reply via email to

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