Project

General

Profile

Actions

Bug #13631

closed

shell lint about variable expansion in arithmetic expressions is inscrutable

Added by Robert Mustacchi about 1 year ago. Updated about 1 year 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 had a bit of code that pbchk was upset about:

if (( $pcidb_exit == 0 )); then
        printf "All tests passed successfully!\n" 
fi

pbchk said: " line 219: variable expansion makes arithmetic evaluation less efficient"

The problem with this message is that you need to realize that in arithmetic evaluation context that you can actually reference variable names directly without the $ and that including it changes things around. If you're not familiar with this error message, this is mostly inscrutable. For example, the native translation from the other pbchk error message about writing this as if [[ $pcidb_exit -eq 0 ]] will tell you to use arithmetic expressions instead. It'd really help to have these pbchk error messages be something that explain what's wrong for folks who aren't as familiar with all the intricacies of the shell especially as they're being told to rewrite things from a form that is certainly correct to another form to appease pbchk.


Related issues

Related to illumos gate - Bug #13601: ksh shell lint misleadingClosedAndy Fiddaman

Actions
Related to illumos gate - Feature #14277: Improve shell lint checksClosedAndy Fiddaman

Actions
Actions

Also available in: Atom PDF