backgroud task on demand? 

Newsgroups: comp.unix.shell
> how can I control whether to put the group of
>commands in background by a variable. I.e, I wish I could do sth like
>this:
>
> { cmd1; cmd2; ... ; cmdn ; } ${background_execution-'&'}

Well, it's not precisely what you're asking for, but how about the functionally similar:

{ cmd1; cmd2; ... ; cmdn ; } &
case ${background_execution+set} in "") wait ;; esac

?

Or, if there is some subtlety which somehow makes that inappropriate, how about:

eval '{ cmd1; cmd2; ... ; cmdn ; } '${background_execution-&}

?

Ken Pizzini

backgroud task on demand? 

>Anyway, >&2 seems to be working is sh.
>
>Because we say
>
>echo xxx > somewhere
>
>and we don't explitly say
>
>echo xxx 1> somewhere

You're correct. 1> and > are equivalent, whether they're followed by a filename or &<digit>, as are 0< and <. Michael saw the >& and didn't notice that it was part of sh's >&<digit> syntax, and jumped the gun on his criticism.

Barry Margolin

documented on: 07-14-99