• # Shellcheck ?

    Posté par (site web personnel) . En réponse au journal yb : quelques nouveautés avant la v1. Évalué à 10.

    Est-ce un choix de ne pas faire de tests avec Shellcheck ? Il y a pas mal de choses qui paraissent faciles à corriger en tout cas, et un shellcheck content est plutôt une bonne chose pour du shell, notamment pour donner plus confiance.

    $ shellcheck yb 2>&1|grep SC|sed 's/^.*SC/SC/;s/: [^ ]* appears/: XXX appears/'|sort|uniq -c
     75 SC2004 (style): $/${} is unnecessary on arithmetic variables.
     2 SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
     17 SC2034 (warning): XXX appears unused. Verify use (or export if used externally).
     1 SC2076 (warning): Remove quotes from right-hand side of =~ to match as a regex rather than literally.
     6 SC2086 (info): Double quote to prevent globbing and word splitting.
     1 SC2104 (error): In functions, use return instead of continue.
     1 SC2104 -- In functions, use return instead ...
     1 SC2116 (style): Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
     6 SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
     16 SC2128 (warning): Expanding an array without an index only gives the first element.
     1 SC2145 -- Argument mixes string and array. ...
     1 SC2145 (error): Argument mixes string and array. Use * or separate argument.
     1 SC2155 (warning): Declare and assign separately to avoid masking return values.
     12 SC2178 (warning): Variable was used as an array but is now assigned a string.
     2 SC2179 (warning): Use array+=("item") to append items to an array.
     1 SC2199 -- Arrays implicitly concatenate in ...
     7 SC2199 (error): Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).
     14 SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
     1 SC2220 (warning): Invalid flags are not handled. Add a *) case.