Project

General

Profile

Actions

Feature #13474

closed

pbchk could lint shell scripts

Added by Andy Fiddaman 10 months ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
tools - gate/build tools
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

I'm going through and cleaning up a number of errors in the shell scripts within gate, and it would be nice if pbchk was extended to do basic lint checking using shcomp

% git pbchk -p upstream_gate
Comments:
These comments are not valid bugs:
  test
  pbchk could check shell scripts

Copyrights:
usr/src/tools/onbld/Checks/__init__.py: no copyright claim for current year found
usr/src/tools/scripts/git-pbchk.py: no copyright claim for current year found

Shell lint:
usr/src/lib/brand/shared/zone/common.ksh: warning: line 401: Invariant test
usr/src/lib/brand/shared/zone/common.ksh: warning: 462: parameter substitution requires unnecessary string to number conversion
usr/src/lib/brand/shared/zone/common.ksh: warning: 524: parameter substitution requires unnecessary string to number conversion
usr/src/lib/brand/shared/zone/common.ksh: warning: 877: parameter substitution requires unnecessary string to number conversion
usr/src/lib/brand/shared/zone/common.ksh: warning: line 957: '=' obsolete, use '=='
usr/src/lib/brand/shared/zone/common.ksh: warning: 999: parameter substitution requires unnecessary string to number conversion

white space nits:
usr/src/lib/brand/shared/zone/common.ksh:372: has trailing spaces
usr/src/lib/brand/shared/zone/common.ksh:415: has trailing spaces
usr/src/lib/brand/shared/zone/common.ksh:506: has trailing spaces
usr/src/lib/brand/shared/zone/common.ksh:526: has trailing spaces
usr/src/lib/brand/shared/zone/common.ksh:874: has trailing spaces

Actions #1

Updated by Andy Fiddaman 10 months ago

  • Gerrit CR set to 1185
Actions #2

Updated by Andy Fiddaman 10 months ago

This new check relies on shcomp being in the path. I tested what happens if it is not and the Shell lint section just ends up with an appropriate error, it does not prevent the rest of the checks being run.

% git pbchk -p upstream_gate
Comments:
WARNING: Blank line(s) in comments
These comments are not valid bugs:
  test
  Change-ID: Ie2678c61048a5cb9ad3c2a8a4833d241a2d6e00a

Shell lint:
Could not execute shcomp: [Errno 2] No such file or directory: 'shcomp': 'shcomp'

white space nits:
usr/src/lib/brand/shared/zone/common.ksh:372: has trailing spaces
usr/src/lib/brand/shared/zone/common.ksh:415: has trailing spaces
usr/src/lib/brand/shared/zone/common.ksh:506: has trailing spaces
usr/src/lib/brand/shared/zone/common.ksh:526: has trailing spaces
usr/src/lib/brand/shared/zone/common.ksh:874: has trailing spaces
Actions #3

Updated by Andy Fiddaman 10 months ago

Testing was basically making a small change to an existing shell script, committing it and running the new pbchk to confirm that it catches shell lint problems. Also running pbchk on changes which do not touch shell scripts and confirming that the output is unchanged.

An example:

build:ig_13474_shelllint:ig_13474_shelllint% echo >> usr/src/lib/brand/solaris10/zone/common.ksh
build:ig_13474_shelllint:ig_13474_shelllint% git commit -m test usr/src/lib/brand/solaris10/zone/common.ksh
[ig_13474_shelllint f26540c50e] test
 1 file changed, 1 insertion(+)
build:ig_13474_shelllint:ig_13474_shelllint%
build:ig_13474_shelllint:ig_13474_shelllint% git pbchk -p upstream_gate
Comments:
WARNING: Blank line(s) in comments
These comments are not valid bugs:
  test
  Change-ID: Ie2678c61048a5cb9ad3c2a8a4833d241a2d6e00a

Copyrights:
usr/src/pkg/manifests/developer-build-onbld.mf: no copyright claim for current year found
usr/src/lib/brand/solaris10/zone/common.ksh: no copyright claim for current year found

Shell lint:
usr/src/lib/brand/solaris10/zone/common.ksh: 94: parameter substitution requires unnecessary string to number conversion
usr/src/lib/brand/solaris10/zone/common.ksh: 151: parameter substitution requires unnecessary string to number conversion
usr/src/lib/brand/solaris10/zone/common.ksh: 156: parameter substitution requires unnecessary string to number conversion
usr/src/lib/brand/solaris10/zone/common.ksh: 174: parameter substitution requires unnecessary string to number conversion
usr/src/lib/brand/solaris10/zone/common.ksh: 179: parameter substitution requires unnecessary string to number conversion
usr/src/lib/brand/solaris10/zone/common.ksh: line 202: '=' obsolete, use '=='
usr/src/lib/brand/solaris10/zone/common.ksh: line 317: -ne within [[...]] obsolete, use ((...))
usr/src/lib/brand/solaris10/zone/common.ksh: line 355: -ne within [[...]] obsolete, use ((...))
usr/src/lib/brand/solaris10/zone/common.ksh: line 355: -ne within [[...]] obsolete, use ((...))

white space nits:
usr/src/lib/brand/solaris10/zone/common.ksh:228: space tab sequences
usr/src/lib/brand/solaris10/zone/common.ksh:230: space tab sequences
usr/src/lib/brand/solaris10/zone/common.ksh:237: space tab sequences
usr/src/lib/brand/solaris10/zone/common.ksh:240: space tab sequences
usr/src/lib/brand/solaris10/zone/common.ksh:241: space tab sequences
usr/src/lib/brand/solaris10/zone/common.ksh:242: space tab sequences
usr/src/lib/brand/solaris10/zone/common.ksh:356: has trailing spaces

Actions #4

Updated by Electric Monk 10 months ago

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

git commit 13904da86c95bce026575f75b430075604bb28e4

commit  13904da86c95bce026575f75b430075604bb28e4
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2021-02-05T10:49:19.000Z

    13474 pbchk could lint shell scripts
    Reviewed by: Toomas Soome <tsoome@me.com>
    Reviewed by: Alexander Eremin <aeremin@tintri.com>
    Approved by: Robert Mustacchi <rm@fingolfin.org>

Actions

Also available in: Atom PDF