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.shellDate : 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/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca