[gull] A propos de shellcheck was Re: [noreply at letsencrypt.org:.

Félix Hauri felix at f-hauri.ch
Fri Apr 11 18:57:23 CEST 2025


Le premier: https://f-hauri.ch/vrac/reshellcheck.sh
partait du constat que la sortie par défaut de shellcheck est lourde!
J'ai donc cherché à ``systématiser'' et réduire la sortie:

  $ ./reshellcheck.sh showColor.sh
  NOTE 4x
     1x SC2015:  Note that A && B || C is not if-then-else. C may run when A is true.
         7 (1):         (( ( pointer - 1 ) % colsperline )) && printf ' ' || { 
     3x SC2086:  Double quote to prevent globbing and word splitting.
        13 (3):            "$color" 0x${color:1:2} 0x${color:3:2} 0x${color:5:2} '' '' ''
  WARNING 1x
     1x SC2183:  This format string has 2 variables, but is passed 1 argument.
         8 (1):             printf -v lines '%*s' $((pointer>1?8:4))
  Total: 5 remarks (4 note, 1 warning).

(A noter que j'utilise la couleur pour situer l'empacement normalement
 indiqué par des lignes (redondantes) commencant par "^".)

En ordonnant les ``notes'' avant les ``warnings'', suivit des ``errors''.
A comparer avec:

  $ shellcheck showColor.sh

  In showColor.sh line 7:
        (( ( pointer - 1 ) % colsperline )) && printf ' ' || { 
                                            ^-- SC2015 (info): Note that A && B || C is not if-then-else. C may run when A is true.


  In showColor.sh line 8:
            printf -v lines '%*s' $((pointer>1?8:4))
                            ^---^ SC2183 (warning): This format string has 2 variables, but is passed 1 argument.


  In showColor.sh line 13:
                 "$color" 0x${color:1:2} 0x${color:3:2} 0x${color:5:2} '' '' ''
                            ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                           ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                          ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

  Did you mean: 
                 "$color" 0x"${color:1:2}" 0x"${color:3:2}" 0x"${color:5:2}" '' '' ''

  For more information:
    https://www.shellcheck.net/wiki/SC2183 -- This format string has 2 variable...
    https://www.shellcheck.net/wiki/SC2015 -- Note that A && B || C is not if-t...
    https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...

Quant au second: https://f-hauri.ch/vrac/parShellCheck.sh

Il parallelise shellcheck et trie les réponses et effecue une stat
d'ensemble:

$ ./parShellCheck.sh <path>

ou

$ ./parShellCheck.sh <file> <file> 

Exemple:

  $ ./parShellCheck.sh showColor.sh coprocDate.source.sh
  Found: 2 files to check with max 4 instances.
     Started                File                                 Rslt microseconds
   - ven 11 18:52:52.504940                                         1        25428
   - ven 11 18:52:52.513505 coprocDate.source.sh                    1        14775
  Succeeded: 0.

  Failed: 2.
   - 
     Shellcheck msgs: 1x SC2015, 3x SC2086, 1x SC2183.
         7: 1xSC2015.
                  (( ( pointer - 1 ) % colsperline )) && printf ' ' || { 
         8: 1xSC2183.
                      printf -v lines '%*s' $((pointer>1?8:4))
        13: 3xSC2086.
                           "$color" 0x${color:1:2} 0x${color:3:2} 0x${color:5:2} '' '' ''
   - coprocDate.source.sh
     Shellcheck msgs: 4x SC1083, 2x SC2086, 1x SC2093.
         8: 2xSC2086.
              echo >&${DATE[1]} "$*"; read -ru ${DATE[0]} out
        12: 4xSC1083, 1xSC2093.
          endDate() { kill "$DATE_PID"; exec {DATE[1]}>&-; exec {DATE[0]}<&-;}
  Overall stat: 12 errors founds but 5 differents errors.
   - SC1083    4 warning:  This { is literal. Check expression (missing ;/\n?) or quote it.
   - SC2015    1 note   :  Note that A && B || C is not if-then-else. C may run when A is true.
   - SC2086    5 note   :  Double quote to prevent globbing and word splitting.
   - SC2093    1 warning:  Remove "exec " if script should continue after this command.
   - SC2183    1 warning:  This format string has 2 variables, but is passed 1 argument.


Le Fri, Apr 11, 2025 at 12:34:09PM +0200, Marc SCHAEFER via gull a écrit :
> > Au fait, tu connais
> >    https://f-hauri.ch/vrac/reshellcheck.sh
> >    https://f-hauri.ch/vrac/parShellCheck.sh
> 
> Non, ça me dépasse :)
> _______________________________________________
> gull mailing list
> gull at forum.linux-gull.ch
> https://forum.linux-gull.ch/mailman/listinfo/gull

-- 
 Félix Hauri  -  <felix at f-hauri.ch>  -  http://www.f-hauri.ch


More information about the gull mailing list