[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Understanding read -r
From: |
Dan Douglas |
Subject: |
Re: [Help-bash] Understanding read -r |
Date: |
Mon, 08 Oct 2012 07:13:49 -0500 |
User-agent: |
KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; ) |
On Friday, October 05, 2012 05:16:13 PM Chet Ramey wrote:
> On 10/4/12 6:58 PM, Dan Douglas wrote:
>
> > As an aside, mksh has an interesting syntax to assign a heredoc result
directly to a variable:
> >
> > # mksh
> >
> > var=<<EOF
> > ...
> > EOF
> >
> > This is optimized to happen in memory with no temporary file.
>
> Is that anything more than syntactic sugar? It doesn't seem different
> enough from multi-line double- or single-quoted strings to make it worth
> adding.
It's not the greatest choice of syntax considering x=<<EOF is already a valid
simple command. There would have to be a POSIX mode exception, and I can't
imagine how many of dark corners would be introduced by supporting it for all
assignments in general.
Better would be to add a type of quoting for specifying string literals
without concern for nested quotes or escapes, especially for strings that are
code. Abusing the heredoc as a form of quoting is too messy for interactive
use, only slightly less messy in a script, and not quite the right thing when
all you really want is to inject a string someplace without the shell touching
it.
--
Dan Douglas