Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Q: What do you call a blind, deaf-mute, quadraplegic Virginian? A: Trustworthy.


comp / comp.unix.shell / Re: Another 'What's the diff Q" (LDo will like this)

SubjectAuthor
* Another 'What's the diff Q" (LDo will like this)Kenny McCormack
+* Re: Another 'What's the diff Q" (LDo will like this)Janis Papanagnou
|`* Re: Another 'What's the diff Q" (LDo will like this)Kenny McCormack
| `* Re: Another 'What's the diff Q" (LDo will like this)Janis Papanagnou
|  +- Re: Another 'What's the diff Q" (LDo will like this)Kenny McCormack
|  `* Re: Another 'What's the diff Q" (LDo will like this)Kenny McCormack
|   `* Re: Another 'What's the diff Q" (LDo will like this)Janis Papanagnou
|    `* Re: Another 'What's the diff Q" (LDo will like this)Kenny McCormack
|     `* Re: Another 'What's the diff Q" (LDo will like this)Kaz Kylheku
|      `* Re: Another 'What's the diff Q" (LDo will like this)Kenny McCormack
|       +* Re: Another 'What's the diff Q" (LDo will like this)Kaz Kylheku
|       |`* Re: Another 'What's the diff Q" (LDo will like this)Kenny McCormack
|       | `- Re: Another 'What's the diff Q" (LDo will like this)Kaz Kylheku
|       `- Re: Another 'What's the diff Q" (LDo will like this)Kaz Kylheku
`- Re: Another 'What's the diff Q" (LDo will like this)Kaz Kylheku

1
Subject: Another 'What's the diff Q" (LDo will like this)
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Tue, 17 Sep 2024 05:37 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 05:37:25 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vcb4il$234i0$1@news.xmission.com>
Injection-Date: Tue, 17 Sep 2024 05:37:25 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2200128"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

(bash) What is the difference between << and <<<, from a functionality
POV? I.e., is there anything you can do with one but not the other?

I'm talking about this:

$ cmd << 'EOF'
....
....
EOF
$

vs.

$ cmd <<< '
....
....
'
$

Of course I know, as does everybody, that << is legacy and <<< is new, but
it begs the question: Why was <<< added to the language?

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.

--
Adderall, pseudoephed, teleprompter

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 17 Sep 2024 07:30 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 09:30:16 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <vcbb68$3dfds$1@dont-email.me>
References: <vcb4il$234i0$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 17 Sep 2024 09:30:17 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3ff418363c2f95269617ae7ad02c98f4";
logging-data="3587516"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19FP7R76HZw+BHvJ5q3EVpt"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:woogStG9qCDOtGEyzJP54mazLPI=
In-Reply-To: <vcb4il$234i0$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
View all headers

On 17.09.2024 07:37, Kenny McCormack wrote:
> (bash) What is the difference between << and <<<, from a functionality
> POV? I.e., is there anything you can do with one but not the other?
>
> I'm talking about this:
>
> $ cmd << 'EOF'
> ...
> ...
> EOF
> $
>
> vs.
>
> $ cmd <<< '
> ...
> ...
> '
> $
>
> Of course I know, as does everybody, that << is legacy and <<< is new, but
> it begs the question: Why was <<< added to the language?

The '<<<' is basically only a convenience syntax for one-liners.

When it had (first) been introduced by Kornshell there was a slight
difference between the two, '<<' and '<<<'; IIRC, the '<<<' did not
create a '\n'. (I had discussed the feature with DGK the days when
it had been introduced. The result, DGK's decision, is what you see.)

>
> 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's actually a restriction since it doesn't allow (e.g.) to control
variable expansion (as is possible with escaping the tag ('EOF' in
your example, which prevents exüpansion, vs. unquoted/unescaped EOF ).

And, of course, Kornshell allows yet more control features with '<<';
see its man-page for the '<<#' variant.

Janis

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Tue, 17 Sep 2024 13:10 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 13:10:27 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vcbv43$23gsl$1@news.xmission.com>
References: <vcb4il$234i0$1@news.xmission.com> <vcbb68$3dfds$1@dont-email.me>
Injection-Date: Tue, 17 Sep 2024 13:10:27 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2212757"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vcbb68$3dfds$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.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's actually a restriction since it doesn't allow (e.g.) to control
>variable expansion (as is possible with escaping the tag ('EOF' in
>your example, which prevents expansion, vs. unquoted/unescaped EOF ).

Well, not really. I can always do:

$ cmd << EOF
$(fortune)
EOF
$

and/or:

$ cmd <<< "
$(fortune)
"
$

Same diff, innit?

--
They say that Trump is a stupid man's idea of a clever man, a poor man's
idea of a rich man, and a weak man's idea of a strong man.

Well, Melania is an unclassy man's idea of classy.

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 17 Sep 2024 15:38 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 17:38:59 +0200
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <vcc7qk$3j1r6$1@dont-email.me>
References: <vcb4il$234i0$1@news.xmission.com> <vcbb68$3dfds$1@dont-email.me>
<vcbv43$23gsl$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 17 Sep 2024 17:39:01 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3ff418363c2f95269617ae7ad02c98f4";
logging-data="3770214"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/m9cXIkjh8CcWpY4lV1qpR"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:prRWdgTV4HwxH87wBntT+NhrrZs=
In-Reply-To: <vcbv43$23gsl$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
View all headers

On 17.09.2024 15:10, Kenny McCormack wrote:
> In article <vcbb68$3dfds$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.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's actually a restriction since it doesn't allow (e.g.) to control
>> variable expansion (as is possible with escaping the tag ('EOF' in
>> your example, which prevents expansion, vs. unquoted/unescaped EOF ).
>
> Well, not really. I can always do:

Ah, of course!

So what remains then is only '<<<' being a one-liner shortcut and
the '<<-' (plus the '<<#' in ksh) features to control indentation,
I suppose.

Janis

>
> $ cmd << EOF
> $(fortune)
> EOF
> $
>
> and/or:
>
> $ cmd <<< "
> $(fortune)
> "
> $
>
> Same diff, innit?
>

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Tue, 17 Sep 2024 15:49 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 15:49:23 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vcc8e3$23kk6$1@news.xmission.com>
References: <vcb4il$234i0$1@news.xmission.com> <vcbb68$3dfds$1@dont-email.me> <vcbv43$23gsl$1@news.xmission.com> <vcc7qk$3j1r6$1@dont-email.me>
Injection-Date: Tue, 17 Sep 2024 15:49:23 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2216582"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vcc7qk$3j1r6$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>So what remains then is only '<<<' being a one-liner shortcut and
>the '<<-' (plus the '<<#' in ksh) features to control indentation,
>I suppose.

Now, I wonder about the actual implementation. In early versions of the
Bourne shell, using << actually created a temp file somewhere (perhaps in /tmp),
which raises the specter of that file not getting removed in crash scenarios.

I don't suppose that is still a cause for concern. What about <<<? How is
that implemented?

--
"Unattended children will be given an espresso and a free kitten."

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Tue, 17 Sep 2024 15:54 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 15:54:38 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vcc8nu$23kk6$2@news.xmission.com>
References: <vcb4il$234i0$1@news.xmission.com> <vcbb68$3dfds$1@dont-email.me> <vcbv43$23gsl$1@news.xmission.com> <vcc7qk$3j1r6$1@dont-email.me>
Injection-Date: Tue, 17 Sep 2024 15:54:38 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2216582"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vcc7qk$3j1r6$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>So what remains then is only '<<<' being a one-liner shortcut and
>the '<<-' (plus the '<<#' in ksh) features to control indentation,
>I suppose.

I just thought of something. Suppose your included text contains both
single and double quotes. This will not be an issue with <<, but will
require extra effort (more than I care to expend!) with <<<.

--
Just for a change of pace, this sig is *not* an obscure reference to
comp.lang.c...

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 17 Sep 2024 17:39 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 19:39:38 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <vccesq$3kjv7$1@dont-email.me>
References: <vcb4il$234i0$1@news.xmission.com> <vcbb68$3dfds$1@dont-email.me>
<vcbv43$23gsl$1@news.xmission.com> <vcc7qk$3j1r6$1@dont-email.me>
<vcc8nu$23kk6$2@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 17 Sep 2024 19:39:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3ff418363c2f95269617ae7ad02c98f4";
logging-data="3821543"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1gNPehugLEINk0yFIH9xs"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:bgZ26OaEA3RbVFw3itqpPt7tefI=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <vcc8nu$23kk6$2@news.xmission.com>
View all headers

On 17.09.2024 17:54, Kenny McCormack wrote:
> In article <vcc7qk$3j1r6$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> ...
>> So what remains then is only '<<<' being a one-liner shortcut and
>> the '<<-' (plus the '<<#' in ksh) features to control indentation,
>> I suppose.
>
> I just thought of something. Suppose your included text contains both
> single and double quotes. This will not be an issue with <<, but will
> require extra effort (more than I care to expend!) with <<<.

That's actually the property I like with here-docs; that you can
write your template-like text inside the shell-program text as it
shall (and will) be seen at the target side, both forms of quotes
inclusive.

As might have already got obvious, though, I use the '<<<' syntax
for other purposes than for such template files; for one-liners. In
that context mixed quote forms are not typical (IME) so that this
property of '<<' is not that important for me to have in '<<<'.[*]

Janis

[*] Such a quote-mixture seems to appear mostly in longer text that
I anyway generally implement with '<<' (if only for its additional
feature to control indentation and thereby make the whole text more
legible).

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 17 Sep 2024 17:41 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 17:41:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <20240917103249.903@kylheku.com>
References: <vcb4il$234i0$1@news.xmission.com>
Injection-Date: Tue, 17 Sep 2024 19:41:51 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3f3af7de1de8264634d3a033bf168553";
logging-data="3816479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UA8ebJMY0TzgkaWWGl3WJOUUckWwgSnU="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:s92v0Xb+KAvl2NVeeU2H5mVbaWY=
View all headers

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

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Tue, 17 Sep 2024 18:57 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 18:57:41 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vccjf5$23rk4$1@news.xmission.com>
References: <vcb4il$234i0$1@news.xmission.com> <vcc7qk$3j1r6$1@dont-email.me> <vcc8nu$23kk6$2@news.xmission.com> <vccesq$3kjv7$1@dont-email.me>
Injection-Date: Tue, 17 Sep 2024 18:57:41 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2223748"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vccesq$3kjv7$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>> I just thought of something. Suppose your included text contains both
>> single and double quotes. This will not be an issue with <<, but will
>> require extra effort (more than I care to expend!) with <<<.
>
>That's actually the property I like with here-docs; that you can
>write your template-like text inside the shell-program text as it
>shall (and will) be seen at the target side, both forms of quotes
>inclusive.

Right. The point I was making is that this rates as a superiority of <<
over <<< - and answers the question posted in the OP: Is there anything one
can do that the other cannot?

>As might have already got obvious, though, I use the '<<<' syntax
>for other purposes than for such template files; for one-liners. In
>that context mixed quote forms are not typical (IME) so that this
>property of '<<' is not that important for me to have in '<<<'.[*]

Right. Got it.

--
Politics is show business for ugly people.

Sports is politics for stupid people.

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 17 Sep 2024 20:34 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 20:34:25 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 80
Message-ID: <20240917132221.49@kylheku.com>
References: <vcb4il$234i0$1@news.xmission.com>
<vcc7qk$3j1r6$1@dont-email.me> <vcc8nu$23kk6$2@news.xmission.com>
<vccesq$3kjv7$1@dont-email.me> <vccjf5$23rk4$1@news.xmission.com>
Injection-Date: Tue, 17 Sep 2024 22:34:26 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3f3af7de1de8264634d3a033bf168553";
logging-data="3879243"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5wooCmK5yqrmwWezjk4INfr+77yf24Ds="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:iiE/78YKRygZWealef1pzIXzMts=
View all headers

On 2024-09-17, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <vccesq$3kjv7$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> ...
>>> I just thought of something. Suppose your included text contains both
>>> single and double quotes. This will not be an issue with <<, but will
>>> require extra effort (more than I care to expend!) with <<<.
>>
>>That's actually the property I like with here-docs; that you can
>>write your template-like text inside the shell-program text as it
>>shall (and will) be seen at the target side, both forms of quotes
>>inclusive.
>
> Right. The point I was making is that this rates as a superiority of <<
> over <<< - and answers the question posted in the OP: Is there anything one
> can do that the other cannot?

Many years ago, I was working on an embedded Linux distro (from
scratch). For text files installed on the target system, like /etc,
I had a Makefile-based thing which could preprocess files with several
preprocessors, based on their suffix. One of the preprocessors was
shell. For those files, what the Makefile did was dynamically
generate a temporary script like this:

cat <<ENDMARKER
# pasted copy of the template file here
ENDMARKER

and then execute the temporary script.

What I'm getting at is that nothing had to be done to the template
file text.

If <<< is used, then the whole template is a quoted field, using
either single quotes and double quotes.

We cannot generate this:

cat <<<'
# pasted copy of the template file here
'

Because the template file could contain single quotes, which would
have to be turned into '\''.

Similarly, we cannot blindly generate this:

cat <<<"
# pasted copy of the template file here
"

because double quotes need escaping now. This is the variant we
would have to use in the templating system because the template
files relied on interpolating the output of variables and
shell commands:

$(for x in a b c; do echo blah $x; done)

So in fact this is backwards; the <<< syntax can likely produce
all the output that << can, but it requires quoting, which requires
escaping that << does not require.

E.g. we can do this:

$ cat <<!
'$USER
!
'kaz

There is an unbalanced quote there, which is just a verbatim
character. Not a problem in a here-doc.

In this sense, the <<< syntax does less: it requires quoting, which
protects fewer character sequences from being interpeted specially. It
does so for the benefit of its inline syntax.

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

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Tue, 17 Sep 2024 20:39 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 20:39:05 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vccpd9$23si3$1@news.xmission.com>
References: <vcb4il$234i0$1@news.xmission.com> <vccesq$3kjv7$1@dont-email.me> <vccjf5$23rk4$1@news.xmission.com> <20240917132221.49@kylheku.com>
Injection-Date: Tue, 17 Sep 2024 20:39:05 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2224707"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <20240917132221.49@kylheku.com>,
Kaz Kylheku <643-408-1753@kylheku.com> wrote:
>On 2024-09-17, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> In article <vccesq$3kjv7$1@dont-email.me>,
>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> ...
>>>> I just thought of something. Suppose your included text contains both
>>>> single and double quotes. This will not be an issue with <<, but will
>>>> require extra effort (more than I care to expend!) with <<<.
>>>
>>>That's actually the property I like with here-docs; that you can
>>>write your template-like text inside the shell-program text as it
>>>shall (and will) be seen at the target side, both forms of quotes
>>>inclusive.
>>
>> Right. The point I was making is that this rates as a superiority of <<
>> over <<< - and answers the question posted in the OP: Is there anything one
>> can do that the other cannot?
>
>Many years ago, I was working on an embedded Linux distro (from
>scratch). For text files installed on the target system, like /etc,
>I had a Makefile-based thing which could preprocess files with several
>preprocessors, based on their suffix. One of the preprocessors was
>shell. For those files, what the Makefile did was dynamically
>generate a temporary script like this:

Perhaps you misread my post. Perhaps you misread "superiority" as
"inferiority". I admit that the two words do look pretty similar.

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/InsaneParty

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 17 Sep 2024 21:15 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 21:15:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <20240917140842.283@kylheku.com>
References: <vcb4il$234i0$1@news.xmission.com>
<vccesq$3kjv7$1@dont-email.me> <vccjf5$23rk4$1@news.xmission.com>
<20240917132221.49@kylheku.com> <vccpd9$23si3$1@news.xmission.com>
Injection-Date: Tue, 17 Sep 2024 23:15:06 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3f3af7de1de8264634d3a033bf168553";
logging-data="3892908"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Z9H1o4lMVAKUJIKjlg8fUlojJe/lakU4="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:IFotNUWJIY5qOYi7at7jnV6FzQA=
View all headers

On 2024-09-17, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <20240917132221.49@kylheku.com>,
> Kaz Kylheku <643-408-1753@kylheku.com> wrote:
>>On 2024-09-17, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>>> In article <vccesq$3kjv7$1@dont-email.me>,
>>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>> ...
>>>>> I just thought of something. Suppose your included text contains both
>>>>> single and double quotes. This will not be an issue with <<, but will
>>>>> require extra effort (more than I care to expend!) with <<<.
>>>>
>>>>That's actually the property I like with here-docs; that you can
>>>>write your template-like text inside the shell-program text as it
>>>>shall (and will) be seen at the target side, both forms of quotes
>>>>inclusive.
>>>
>>> Right. The point I was making is that this rates as a superiority of <<
>>> over <<< - and answers the question posted in the OP: Is there anything one
>>> can do that the other cannot?
>>
>>Many years ago, I was working on an embedded Linux distro (from
>>scratch). For text files installed on the target system, like /etc,
>>I had a Makefile-based thing which could preprocess files with several
>>preprocessors, based on their suffix. One of the preprocessors was
>>shell. For those files, what the Makefile did was dynamically
>>generate a temporary script like this:
>
> Perhaps you misread my post. Perhaps you misread "superiority" as
> "inferiority". I admit that the two words do look pretty similar.

No I didn't misread; but that's what it is. While the <<<
syntax represents a certain kind of improvement in that it doesn't
require weird parsing (line-oriented fetching of data that is out of
band with regard to the phrase structure syntax of the shell language),
it has disadvantages due to the increased complexity of quoting.

If you want to produce some templated text with shell interpolation,
with minimal uncertainties with regard to quoting, <<< is in fact
inferior.

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

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 17 Sep 2024 22:44 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 22:44:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <20240917152931.879@kylheku.com>
References: <vcb4il$234i0$1@news.xmission.com>
<vccesq$3kjv7$1@dont-email.me> <vccjf5$23rk4$1@news.xmission.com>
<20240917132221.49@kylheku.com> <vccpd9$23si3$1@news.xmission.com>
Injection-Date: Wed, 18 Sep 2024 00:44:08 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6e7348e4bd804227446ed48a52cff9c3";
logging-data="3918908"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mfXaJdagaHBfwxiI11+Qq7pQcxa9tjfU="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:PM2BH8+hCA38ZXMxc4CWeycpc9A=
View all headers

On 2024-09-17, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> Perhaps you misread my post. Perhaps you misread "superiority" as
> "inferiority". I admit that the two words do look pretty similar.

Here is a superiority. Because the <<< construct uses the ordinary
expansions in a command line, it is useful in a situation in which we
have an existing command that takes some complicated expansion as an
argument, and we would like to use that as standard input. The <<<
construct lets us do that without having to convert everything in that
complicated expansion into a here document.

It's not that we can't convert that content it to a here document, but
it takes work, and could introduce a bug.

So it's just tradeoffs. Some aspect that is an advantage in one
situation is a disadvantage in another, and so it goes.

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

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Tue, 17 Sep 2024 22:55 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Tue, 17 Sep 2024 22:55:04 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vcd1c8$242ot$1@news.xmission.com>
References: <vcb4il$234i0$1@news.xmission.com> <20240917132221.49@kylheku.com> <vccpd9$23si3$1@news.xmission.com> <20240917140842.283@kylheku.com>
Injection-Date: Tue, 17 Sep 2024 22:55:04 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2231069"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <20240917140842.283@kylheku.com>,
Kaz Kylheku <643-408-1753@kylheku.com> wrote:
....
>If you want to produce some templated text with shell interpolation,
>with minimal uncertainties with regard to quoting, <<< is in fact
>inferior.

You really might want to go back and check up on your reading skills.

Note: We are in violent agreement.

--
People who say they'll vote for someone else because Obama couldn't fix
*all* of Bush's messes are like people complaining that he couldn't cure
cancer, so they'll go and vote for (more) cancer.

Subject: Re: Another 'What's the diff Q" (LDo will like this)
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Wed, 18 Sep 2024 01:47 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Another 'What's the diff Q" (LDo will like this)
Date: Wed, 18 Sep 2024 01:47:41 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <20240917183351.606@kylheku.com>
References: <vcb4il$234i0$1@news.xmission.com>
<20240917132221.49@kylheku.com> <vccpd9$23si3$1@news.xmission.com>
<20240917140842.283@kylheku.com> <vcd1c8$242ot$1@news.xmission.com>
Injection-Date: Wed, 18 Sep 2024 03:47:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6e7348e4bd804227446ed48a52cff9c3";
logging-data="3970737"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/51UTsUTNrG6UnGL8E25Dyq8F0ZBTxmmw="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:qIZpPXB/phlTYLNXBlkD+WFGySQ=
View all headers

On 2024-09-17, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <20240917140842.283@kylheku.com>,
> Kaz Kylheku <643-408-1753@kylheku.com> wrote:
> ...
>>If you want to produce some templated text with shell interpolation,
>>with minimal uncertainties with regard to quoting, <<< is in fact
>>inferior.
>
> You really might want to go back and check up on your reading skills.

I really don't understand the point of this remark.

Yes, it's clear you wanted to know if an extension in Bash does
something that strictly can't be done with its standard cousin.

In the computational sense, it almost certainly does not enable the
calculation of output texts that are not out of reach to <<.

It does express things differently such that some things that can
be done /in a certain way/ with one thing cannot be with the other
and vice versa.

> Note: We are in violent agreement.

Not only that, but it doesn't even look like anything has been posited
in disagreeing terms or that anyone (visible to me) thinks there is a
disagreement.

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

1

rocksolid light 0.9.8
clearnet tor