Re: Another 'What's the diff Q" (LDo will like this)

Liste des GroupesRevenir à cu shell 
Sujet : Re: Another 'What's the diff Q" (LDo will like this)
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.shell
Date : 17. Sep 2024, 18:41:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240917103249.903@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-09-17, Kenny McCormack <gazelle@shell.xmission.com> wrote:
Note that I use both constructs, as the mood suits me, but I just got to
thinking that maybe <<< doesn't actually add any new functionality.

It rearranges the syntax so that the data whicha are destined for a
command's standard input are presented in the command line, rather
than as extra lines in the shell script below the command line.

Consider that we have two cat commands in a single command line.  How do
we feed them here docs? They have to be extraposed after the entire
command line:


  cat <<! ; cat <<!
  foo
  !
  bar
  !

The left cat gets foo, the right cat gets bar. This is kind of gross.
It reminds you of READ statements in BASIC which look for DATA
later in the program.

Also, think of the pains people go through to indent here docs
nicely when they occur in nested code.

Suppose you have some multi-line text in a variable "var", and would
like to pipe that text into a command (and nothing but that text).
It's obviously nicer to just do cmd <<<$var rather than

  cmd <<!
  $var
  !

Moreover, I think, the latter will send an extra newline to the
command. If the last line in $var already has a newline, that
results in a spurious blank line, am I right?

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
17 Sep 24 * Another 'What's the diff Q" (LDo will like this)15Kenny McCormack
17 Sep 24 +* Re: Another 'What's the diff Q" (LDo will like this)13Janis Papanagnou
17 Sep 24 i`* Re: Another 'What's the diff Q" (LDo will like this)12Kenny McCormack
17 Sep 24 i `* Re: Another 'What's the diff Q" (LDo will like this)11Janis Papanagnou
17 Sep 24 i  +- Re: Another 'What's the diff Q" (LDo will like this)1Kenny McCormack
17 Sep 24 i  `* Re: Another 'What's the diff Q" (LDo will like this)9Kenny McCormack
17 Sep 24 i   `* Re: Another 'What's the diff Q" (LDo will like this)8Janis Papanagnou
17 Sep 24 i    `* Re: Another 'What's the diff Q" (LDo will like this)7Kenny McCormack
17 Sep 24 i     `* Re: Another 'What's the diff Q" (LDo will like this)6Kaz Kylheku
17 Sep 24 i      `* Re: Another 'What's the diff Q" (LDo will like this)5Kenny McCormack
17 Sep 24 i       +* Re: Another 'What's the diff Q" (LDo will like this)3Kaz Kylheku
18 Sep 24 i       i`* Re: Another 'What's the diff Q" (LDo will like this)2Kenny McCormack
18 Sep 24 i       i `- Re: Another 'What's the diff Q" (LDo will like this)1Kaz Kylheku
18 Sep 24 i       `- Re: Another 'What's the diff Q" (LDo will like this)1Kaz Kylheku
17 Sep 24 `- Re: Another 'What's the diff Q" (LDo will like this)1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal