help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Understanding read -r


From: Pierre Gaston
Subject: Re: [Help-bash] Understanding read -r
Date: Fri, 5 Oct 2012 08:57:52 +0300



On Fri, Oct 5, 2012 at 3:00 AM, Dan Douglas <address@hidden> wrote:
On Thursday, October 04, 2012 05:25:55 PM Eric Blake wrote:
> On 10/04/2012 05:16 PM, Bob Proulx wrote:
>
> >> { var=$(</dev/stdin); } <<EOF
>
> >
> > I personally dislike the use of /dev/stdin and the others because they
> > are non-portable across kernels and cause me trouble.
>
> Bash special-cases /dev/stdin so that it works even if your kernel
> doesn't support it.  Of course, that special casing is only applicable
> to situations where bash is opening the file, and not where you pass the
> string '/dev/stdin/ as an argument to some other program, so I tend to
> agree with your analysis that it gets even harder to use when it works
> in some, but not all, contexts within the same machine.

Oh it applies to builtins opening the file passed as an argument too? I
thought it was only special redirection syntax (like in this case). If that's
true I might use the tee loadable more frequently.

> >> var=<<EOF
> >> ...
> >> EOF
> >>
> >> This is optimized to happen in memory with no temporary file.
> >
> > Looks like a nice feature.
>
> How is it any different from:
> var="...
> "

Just in the handling of escapes and nested quotes. I imagine the quoted
delimiter variant is more useful. Example usecase:

defaultTrap=<<'EOF'
...
EOF

here docs also allow to somehow indent the code with tabs:
<tab>var=<<-EOF
<tab><tab>foo




reply via email to

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