[Top][All Lists]

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

Re: setting SHELL to ssh script for load sharing parallel make

From: Philip Guenther
Subject: Re: setting SHELL to ssh script for load sharing parallel make
Date: Fri, 29 Aug 2008 22:55:28 -0600

On Fri, Aug 29, 2008 at 6:42 AM, Martin <address@hidden> wrote:
> I thought of setting SHELL to some ssh script to allow load sharing of
> parallel make (when you use -j). But I have techical difficulties: line
> continuations do not work well. This simplest form I have:
> $ cat myshell
> #!/bin/bash
> # Turn $* into an array to remove -c
> args=( `echo $*` )
> ssh localhost "cd $PWD; ${args[*]:1}"
> I suspect it has to do with the shell and not with make, although make does
> pass the line continuation character "\" without passing the newline to
> ./myshell (echo $* to see).

That's no correct.  Make passes exactly two arguments to $SHELL.  The
first is "-c", the second is an entire command from the rule.  If it
includes continuations, the backslash and newline are both part of
that argument.  You didn't see that because your myshell script
resplit the argument on $IFS instead of evaluating it.  You can see
this by setting SHELL to point to this script:

    for i do
        printf '-->%s<--\n' "$i"

That'll show how there are two arguments and the second includes the
command, backslashes and newlines and all.

Anyway, so you need to evaluate the second argument.  The good news is
that 'ssh' passes its command to the shell on the remote end, so a
round of evaluation will happen there for you.  All you need to do is
include $2 in the command for ssh to execute on the remote end:
    ssh localhost "cd $PWD || exit; $2"

Philip Guenther

reply via email to

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