[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Format of here-documents
From: |
goncholden |
Subject: |
Re: Format of here-documents |
Date: |
Tue, 14 Mar 2023 15:01:57 +0000 |
Sent with Proton Mail secure email.
------- Original Message -------
On Wednesday, March 15th, 2023 at 2:28 AM, Andreas Kusalananda Kähäri
<andreas.kahari@abc.se> wrote:
> On Tue, Mar 14, 2023 at 11:58:16AM +0000, goncholden via wrote:
>
> > Have been reading the manual about Here-Documents.
> >
> > The format of here-documents is:
> >
> > [
> >
> > n
> >
> > ]<<[-]
> >
> > word
> >
> > here-document
> >
> > delimiter
> >
> > But in practice I have seen the following
> >
> > cat << _end_of_text
> > First Line
> > Second Line
> > Third Line
> > _end_of_text
> >
> > Meaning that 'delimiter' is actually '
> >
> > word'. Is this correct ?
>
>
> From the bash manual:
>
> If any part of word is quoted, the delimiter is the result of
> quote removal on word, and the lines in the here-document are
> not expanded.
>
> Assumign that your issue with the manual is that the displayed syntax
> for here-documents does not say
>
> [n]<<[-]word
> here-document
> word
>
> ... the quoted sentence above should explain why the "word" and
> "delimiter" may be different (they would be if "word" is quoted in any
> way).
I agree, there needs to be more explanation.
The order should be changed, starting with the simplest state (word and
delimiter being the same) first. Separation between "word unquoted" and "word
quoted" is easier to spot whet one is reading rapidly.
Here is an updated version:
--------
No parameter and variable expansion, command substitution, arithmetic
expansion, or filename expansion is performed on word.
If word is unquoted, the delimiter is the same as word, and all lines of the
here-document are subjected to parameter expansion, command substitution, and
arithmetic expansion, the character sequence \newline is ignored, and ‘\’ must
be used to quote the characters ‘\’, ‘$’, and ‘`’.
If any part of word is quoted, the delimiter is the result of quote removal on
word, and the lines in the here-document are not expanded.
--------
>
> --
> Andreas (Kusalananda) Kähäri
> SciLifeLab, NBIS, ICM
> Uppsala University, Sweden
>
> .
- Format of here-documents, goncholden, 2023/03/14
- Re: Format of here-documents, alex xmb ratchev, 2023/03/14
- Re: Format of here-documents, Andreas Kusalananda Kähäri, 2023/03/14
- Re: Format of here-documents,
goncholden <=
- Re: Format of here-documents, goncholden, 2023/03/14
- Re: Format of here-documents, Andreas Kusalananda Kähäri, 2023/03/14
- Re: Format of here-documents, Dennis Williamson, 2023/03/14
- Re: Format of here-documents, Jonesy, 2023/03/15
- Re: Format of here-documents, Dennis Williamson, 2023/03/15
- Re: Format of here-documents, Andreas Kusalananda Kähäri, 2023/03/15
- Re: Format of here-documents, Chet Ramey, 2023/03/14
- Re: Format of here-documents, Andreas Kusalananda Kähäri, 2023/03/14