On 2018-04-02 17:55, Bas Zoutendijk wrote:

> What my syntax is doing is to let the $PS1 inside the PS1 definition
> be evaluated by the chroot shell.  Suppose you run this command with
> HOST=eden and ROOT=/mnt/eden:
> 
>     echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot 
> $ROOT /bin/bash -i
> 
> The parent shell will translate this into
> 
>     echo 'export PS1="(chroot 'eden') $PS1"; exec </dev/tty' | exec chroot 
> /mnt/eden /bin/bash -i
> 
> This is where the purpose of the 's around $HOST shows: $HOST is
> outside the single quotes, so gets substituted, while the rest of the
> string, notably $PS1, remains the same.  The child shell will
> therefore receive input
> 
>     export PS1="(chroot eden) $PS1"; exec </dev/tty
> 
> which will prepend the desired text to the child shell’s prompt.

Ah, this is a comedy of errors.  You've missed my intended point, which
was wrong; but now I see the real problem.

I missed the outermost single quotes in your echo command, so I thought
the parent shell would strip the double quotes and then the child shell
would see unquoted whitespace on the right side of the export.

But the real problem is that quotes (either kind by itself or mixed) do
not nest.  So the first single quote will be paired with the one before
$HOST and terminated by it; and the double quote after = will remain
unbalanced and unterminated. 

> Sebastiaan L. Zoutendijk | slzoutend...@gmail.com

And now I learn, at last, that Bas is the Dutch nickname for Sebastiaan.
Thanks for that ;-)

-- 
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
To reply privately _only_ on Usenet and on broken lists
which rewrite From, fetch the TXT record for no-use.mooo.com.

Reply via email to