Re: Using << and an output pipe together in shell (bash)

Liste des GroupesRevenir à cu shell 
Sujet : Re: Using << and an output pipe together in shell (bash)
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.unix.shell
Date : 31. Oct 2024, 21:57:43
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vg0r09$2ro7o$1@dont-email.me>
References : 1
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 31.10.2024 21:44, Kenny McCormack wrote:
Consider this code in a bash script:
 
(Note: No actual indentation is intended - only shown like this for posting)
 
    someCommand ... << EOF | someOtherCommand
    some data
    for someCommand
    EOF
 
This should work, right?
 
In simple cases, it does (seem to) work OK.
 
However, in the actual real world case, it is more like:
 
    someCommand -x -y "sjdfhk" and more options \
-g and still more options -Q "another option" << EOF |
/usr/lib/ANotherCommand -x "with option" and "more options"
    some data
    for someCommand
    EOF

This complexity is not helping much to see what issue you have also
when mentioning syntax highlighting problems.

All I can say at the moment - and you decide whether that's relevant
for your case - is that, say, instead of syntax

  cat \
  -n << EOF |
  wc -l
  some data
  for someCommand
  EOF

you might rather want

  cat \
  -n << EOF |
  some data
  for someCommand
  EOF
  wc -l


HTH.

Janis

 
This time, two things happen:
 
When edited with GVIM, everything after the line that ends with | is
highlighted as if it was an unterminated string (that is, in a purple/pink
color) and when the above file is dotted, bash complains about "Syntax
error: Unexpected end of file" - as if it never seems the EOF tag.
 
In the end, I ended up replacing the " << EOF | ANotherCommand ..." construct with:
 
    > >(ANotherCommand ...) << EOF
 
and all is well.  But why?  Should this be necessary?
Yes, I know it is hard to debug this w/o specifics, but I really don't
think the specifics matter; they would be hard to reproduce here.
 
I just want to know if the basic syntax is valid and/or if there is a
better workaround (better than switching to: > >(...))
 


Date Sujet#  Auteur
31 Oct 24 * Using << and an output pipe together in shell (bash)10Kenny McCormack
31 Oct 24 +- Re: Using << and an output pipe together in shell (bash)1Janis Papanagnou
1 Nov 24 +* Re: Using << and an output pipe together in shell (bash)6Ben Bacarisse
1 Nov 24 i`* Re: Using << and an output pipe together in shell (bash)5Kenny McCormack
1 Nov 24 i +* Re: Using << and an output pipe together in shell (bash)3Janis Papanagnou
1 Nov 24 i i`* Re: Using << and an output pipe together in shell (bash)2Kenny McCormack
1 Nov 24 i i `- Re: Using << and an output pipe together in shell (bash)1Lem Novantotto
1 Nov 24 i `- Re: Using << and an output pipe together in shell (bash)1Kaz Kylheku
3 Nov 24 `* Re: Using << and an output pipe together in shell (bash)2Helmut Waitzmann
4 Nov 24  `- Re: Using << and an output pipe together in shell (bash)1Janis Papanagnou

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal