[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lint warning: unnecessary mixing of `>' and `>>'
From: |
Hermann Peifer |
Subject: |
Re: lint warning: unnecessary mixing of `>' and `>>' |
Date: |
Fri, 20 Oct 2023 10:25:53 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 |
On 20/10/2023 01.38, Andrew J. Schorr wrote:
For #2, doesn't this code give the same result?
awk --lint 'BEGIN { f="out.dat"; print "Hello" >> f; print "World" >> f;
close(f) }'
There is indeed no lint warning in the above case. One could however
imagine a lint warning like this in the above case: Unnecessary double
use of ">>"
I guess the lint code is wondering why you'd bother to write it the first way.
I suppose it's less typing to enter ">" for the second print instead of ">>",
but
maybe ">>" is more consistent.
I bothered because the manual says something like this (loosely
speaking): Using ">>" for redirecting output to a file already opened by
an earlier print statement is unnecessary. In other words: using ">>"
for the second print would show that I haven't read the manual
;-) Hermann
PS: here the original (and somewhat more diplomatically phrased) text
from https://www.gnu.org/software/gawk/manual/html_node/Redirection.html
"Subsequent writes to the same output-file do not erase output-file, but
append to it. (This is different from how you use redirections in shell
scripts.)"
Re: lint warning: unnecessary mixing of `>' and `>>', arnold, 2023/10/21
- Re: lint warning: unnecessary mixing of `>' and `>>', Wolfgang Laun, 2023/10/21
- Re: lint warning: unnecessary mixing of `>' and `>>', Manuel Collado, 2023/10/23
- Re: lint warning: unnecessary mixing of `>' and `>>', arnold, 2023/10/23
- Re: lint warning: unnecessary mixing of `>' and `>>', Wolfgang Laun, 2023/10/23
- Re: lint warning: unnecessary mixing of `>' and `>>', Manuel Collado, 2023/10/24
- Re: lint warning: unnecessary mixing of `>' and `>>', arnold, 2023/10/24