bug-parallel
[Top][All Lists]
Advanced

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

Re: GNU Parallel Bug Reports parallel can't ressigned variablen in the s


From: Andreas Bernauer
Subject: Re: GNU Parallel Bug Reports parallel can't ressigned variablen in the same context in same file
Date: Wed, 30 May 2012 17:11:19 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20120428 Thunderbird/12.0.1

On 5/29/12 11:26, gmail wrote:
> hello
> is it a bug to parallel or parallel can't do like this ?
> 
> today , i used  parallel to my shell script ,but read all the
> document,no referent  about variable ouside parallel.
> 
> bash test code like that:
> 
> ###################
> #!/bin/bash
> 
> foo=33
> 
> parallel "foo=44;echo $foo;"
> 
> above code response 44
> ####################
> 
> 

For me, your code works as I'd expect it:
- $foo gets expanded to 33 before parallel is even run, because '$foo'
is in double quotes ("), not single quotes (')
- parallel does not run anything but awaits input from the terminal,
printing a message about this circumstance.

#############
$ cat /tmp/par
#!/bin/bash
foo=33
parallel "foo=44;echo $foo;"
$ bash /tmp/par
parallel: Input is read from the terminal. Only experts do this on
purpose. Press CTRL-D to exit.
^D
$ bash /tmp/par
parallel: Input is read from the terminal. Only experts do this on
purpose. Press CTRL-D to exit.
1
^D
bash: 1: command not found
33
#############

Note the output '33' after bash's complain.

If you want to use foo in your parallel script, you must take care that
'$foo' is not expanded in the parallel script, for example by escaping
the '$' sign or putting the command in single quotes. Example for the
former:

#####################
$ cat /tmp/par2
#!/bin/bash
foo=33
parallel "foo=44;echo \$foo;"
$ bash /tmp/par2
parallel: Input is read from the terminal. Only experts do this on
purpose. Press CTRL-D to exit.
1
^D
bash: 1: command not found
44
###################

Note that now the output is '44' after bash's complain.

HTH,

Andreas.



reply via email to

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