In article <s8ac15$kfg$
1...@news-1.m-online.net>,
Janis Papanagnou <
janis_pa...@hotmail.com> wrote:
>On 22.05.2021 07:59, some weirdo wrote:
>> On 5/21/2021 7:20 PM, Janis Papanagnou wrote:
>>> On 22.05.2021 01:36, Kenny McCormack wrote:
>> <snip>
>>>> It also complains about things like:
>>>>
>>>> gawk '{ print $1 }'
>>
>> Not it doesn't.
>
>I haven't verified Kenny's example, but I've just tried the statement
>
> gawk "{ print $1 }"
>
>which also gives no warning.
It turns out that shellcheck does, indeed, "know" about "awk" (and "gawk")
as being "special". So, Janis is correct - that invoked as "gawk", it
doesn't complain. However, as it happens, in my coding environment,
whenever I invoke AWK, it is as "gawk4" and, not surprisingly, shellcheck
doesn't recognize that as being a flavor of AWK.
Which is a long-winded way of saying that if you try the above example
using, say, "gawk4", instead of just plain "gawk", it (shellcheck) *will*
flag it.
So, what it boils down to is: Should a tool like shellcheck "know" about
the semantics of the things we generally call "shell tools" (things like
AWK, ls, find, Perl, etc) ? On the one hand, aesthetically, the answer to
this should be "no", because it just feels like a "slippery slope". This
seems to be Janis's position (his original objection to the tool telling
you to use "find" instead of "ls"). Intuitively, the tool *should* be
agnostic w.r.t. choice of tools. I think we can all agree on this -
intuitively.
However, on the other hand, we can all recognize that the usefulness of the
tool is greatly diminished if it doesn't have such knowledge. This seems
to be the position held by that other poster. And, in fact, this is the
position I originally espoused, w.r.t. AWK - that shellcheck *should*
understand about AWK command line scripts and realize that they are
generally single (not double) quoted for a good reason.
Which it, in fact, does. Provided you invoke AWK via a recognized command
name (a set of which "gawk4" is, alas, not a member).
P.S. All comments by in regards to the shellcheck tool are based on my
experience with the normal, downloadable version - which I have used on
some of my own scripts. I have no knowledge or experience with any
"online" version. I assume, however, that they are basically the same.
--
Men rarely (if ever) manage to dream up a God superior to themselves.
Most Gods have the manners and morals of a spoiled child.