Project

General

Profile

Bug #13601

ksh shell lint misleading

Added by Robert Mustacchi about 1 month ago. Updated 5 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

I was working on #13600 and got a piece of shell lint:

Shell lint:
usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh: line 41: -eq within [[...]] obsolete, use ((...))

However, if you just do what you think it says and try to change something like [[ $? -eq 0 ]] to (($? -eq 0)) then ksh just generates an arithmetic errror. One needs to know that it also has to be changed from using -eq to ==. It'd be helpful if it indicated that you need to use ==.


Related issues

Related to illumos gate - Bug #13631: shell lint about variable expansion in arithmetic expressions is inscrutableClosedAndy Fiddaman

Actions
#1

Updated by Robert Mustacchi about 1 month ago

  • Related to Bug #13631: shell lint about variable expansion in arithmetic expressions is inscrutable added
#2

Updated by Andy Fiddaman 11 days ago

  • Category set to cmd - userland programs
  • Status changed from New to In Progress
  • Assignee set to Andy Fiddaman
#3

Updated by Electric Monk 11 days ago

  • Gerrit CR set to 1384
#4

Updated by Andy Fiddaman 11 days ago

With the change in the associated Gerrit review, this changes from:

/data/omnios-build/ksh/linttest: warning: line 3: -eq within [[...]] obsolete, use ((...))
/data/omnios-build/ksh/linttest: warning: line 4: -ne within [[...]] obsolete, use ((...))
/data/omnios-build/ksh/linttest: warning: line 5: -lt within [[...]] obsolete, use ((...))
/data/omnios-build/ksh/linttest: warning: line 6: -gt within [[...]] obsolete, use ((...))
/data/omnios-build/ksh/linttest: warning: line 7: -le within [[...]] obsolete, use ((...))
/data/omnios-build/ksh/linttest: warning: line 8: -ge within [[...]] obsolete, use ((...))

to

/data/omnios-build/ksh/linttest: warning: line 3: [[... -eq ...]] obsolete, use ((... == ...))
/data/omnios-build/ksh/linttest: warning: line 4: [[... -ne ...]] obsolete, use ((... != ...))
/data/omnios-build/ksh/linttest: warning: line 5: [[... -lt ...]] obsolete, use ((... < ...))
/data/omnios-build/ksh/linttest: warning: line 6: [[... -gt ...]] obsolete, use ((... > ...))
/data/omnios-build/ksh/linttest: warning: line 7: [[... -le ...]] obsolete, use ((... <= ...))
/data/omnios-build/ksh/linttest: warning: line 8: [[... -ge ...]] obsolete, use ((... >= ...))
#5

Updated by Electric Monk 5 days ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit c7b656fc7125adc5888ce934f1a3433da4b1bbc5

commit  c7b656fc7125adc5888ce934f1a3433da4b1bbc5
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2021-04-07T19:16:33.000Z

    13601 ksh shell lint misleading
    13631 shell lint about variable expansion in arithmetic expressions is inscrutable
    Reviewed by: Robert Mustacchi <rm@fingolfin.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Also available in: Atom PDF