Greg Wooledge wrote:
> On Fri, Jun 13, 2025 at 07:08:21 -0600, Stan Marsh wrote:
>> BTW, and only tangentially related, "man bash" says that
>> "let" and "(( ))" are exactly the same, but "shellcheck"
>> thinks otherwise.  "shellcheck" says you should use "((
>> ))" and never use "let", but I still (mostly) use "let".
> 
> That's peculiar.  I'm not sure why shellcheck would advise
> using one of them over the other, and in particular, why
> it would advise (( over let.  Maybe it's because of
> quoting issues with let?

There doesn't seem to be a lot of discussion about it, but
the advice to use '((' over 'let' comes from:

    https://github.com/koalaman/shellcheck/issues/813

The issue is stated as:

    let is very similar to (( - the only difference being
    let is a builtin (simple command), and (( is a compound
    command.  The arguments to let are therefore subject to
    all the same expansions and substitutions as any other
    simple command - requiring proper quoting and escaping -
    whereas the contents of (( aren't subject to
    word-splitting or pathname expansion (almost never
    desirable for arithmetic). For this reason, the
    arithmetic compound command should generally be
    preferred over let.[0]

    [0] http://wiki.bash-hackers.org/commands/builtin/let

-- 
Todd

Attachment: signature.asc
Description: PGP signature

Reply via email to