bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unnecessary bash warning message


From: Chet Ramey
Subject: Re: Unnecessary bash warning message
Date: Mon, 8 May 2023 11:13:19 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.1

On 5/7/23 10:06 PM, Hyunho Cho wrote:

Bash Version: 5.2
Patch Level: 15
Release Status: release

#######################################################


Process substitution can be used in place of a file in a command line
as follows:

bash$ cat test.jl
for a in ARGS println(a) end

bash$ julia test.jl 11 22 33
11
22
33

bash$ julia <( cat <<\@
for a in ARGS println(a) end
@
) 11 22 33
11
22
33

However, in the above method, the 11 22 33 arguments are placed at the
end of the command line,
which is not good for readability. So writing the following would make
the command line much more readable,
but it would output unnecessary warning messages.

bash$ julia <( cat <<\@ ) 11 22 33
for a in ARGS println(a) end
@
bash: warning: command substitution: 1 unterminated here-document
11
22
33

The process substitution is in its own parsing environment, from the `(' to
the `)', and the command must be contained within that parsing environment.
That includes any here-documents. Bash warns you that the here-document was
not terminated when the process substitution ends, and, trying to intuit
the true intent, goes ahead and collects here documents from the input
stream. It could be a syntax error, but bash just makes it a warning, so
you can change your code to do it the right way.

I see I might need to update the error message to specify it's process
substitution. Command and process substitution share the same parsing
functions and are identical from that perspective.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]