bug-bash
[Top][All Lists]
Advanced

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

Re: Syntax Question...


From: Greg Wooledge
Subject: Re: Syntax Question...
Date: Thu, 18 Aug 2011 12:44:54 -0400
User-agent: Mutt/1.4.2.3i

On Thu, Aug 18, 2011 at 09:26:42AM -0700, Linda Walsh wrote:
> It's like "-e" was very using in bash 3.0-4.0, but you didn't know it so
> thought it worthless.

I certainly knew about -e.  It was bad back then, too.  It's arguably
worse now, because there are even more variants in implementation than
there were in the bash 3.0 days.

I didn't know about shopt expand_aliases, but now that I do, I never
plan to use it.  If you want to use it, well... good luck.

>    Now that one is suprising, as it's supposed to take the output of
> the ... hmmm.....yup!...  that's exactly what it does.
> takes the work and executes it and returns the results on stdin as
> a single quoted blob of output:
> 
>    >  read a <<< *.txt
>    >  echo $a
>    apc_contact.txt .chklog.txt driver_filename.txt FFcookies.txt
>    qb2.txt rcs_kywds-exmpls.txt return_rma.txt Soundtrack-II.txt
>    Soundtrack-I.txt winsize.txt

No, you've tripped yourself by failing to quote $a in the echo command.
"a" contains *.txt and your unquoted $a is being expanded (parameter
expansion and then pathname expansion) with the resulting filenames
being passed to echo.

"USE MORE QUOTES!"

> 
> But this is weird:
> 
>    { read a b c  } <<<*.txt  <<<*.dat  <<<*.log
>    echo $a,  $b,  $c
>    .bzr.log h.log q.log texput.log

You're not even using valid syntax.  { read a b c; } is what you have
to use, for a one-liner command group.  And the commas in your echo
command are mysteriously absent in your output.

> i.e. the <<<*.txt and <<<*.dat are thrown away.
> Weirdness.

You've placed 3 separate redirections on the same command, but they're all
input redirections (FD 0).  So they're applied left to right in sequence.
The last one wins, as each one clobbers the one before.

imadev:~$ { read a b c; } <<< *.pdf 
imadev:~$ echo "a=<$a> b=<$b> c=<$c>"
a=<*.pdf> b=<> c=<>

When you ran echo $a (presumably you ran echo $a and not echo $a,  $b,  $c
as you indicated) the unquoted $a was expanded to your list of filenames.



reply via email to

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