Journal yb : quelques nouveautés avant la v1

Posté par  . Licence CC By‑SA.
Étiquettes :
4
2
juin
2024

Bonjour communauté linuxfr,

Petit update avant de passer yb en v1. En l'implémentant comme back-end pour le support yaml dans loco.sh, j'ai découvert de forts soucis de compatibilité avec macOS X. En effet, la distribution OS X supporte nativement une version de bash ancienne (3.12) et la version 5.x installable à travers homebrew connait parfois des soucis de namespacing.

Comme en bash, vous décrivez un interpréteur en en-tête du fichier, c'est le système sous-jacent qui choisit la version de bash qui va interpréter votre script. Dans mon cas, en faisant un simple yb sur les dernières versions d'OS X, je n'arrivais pas à faire exécuter mon script en bash 5.x.

Après pas mal de tests, j'ai réussi à implémenter un wrapper qui permet de router l'interprétation du script en fonction de la version de bash initialement appelée par le système. C'est relativement trivial mais à ma connaissance ce problème d'interpréteur Bash dynamique est encore ouvert dans la communauté.

Les plus curieux peuvent aller voir la fonction yb::core::check_bash_version.

Avec cet update, je pense me rapprocher d'une v1 prochaine, avec je pense une v1.1 en fin d'année / début d'année prochaine. Côté loco.sh, je reviens bientôt avec une version Ubuntu 24.04 ready !

À vos likes : https://github.com/t0pd4wn/yb

  • # Shellcheck ?

    Posté par  (site web personnel) . Évalué à 10 (+10/-0).

    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.

Envoyer un commentaire

Suivre le flux des commentaires

Note : les commentaires appartiennent à celles et ceux qui les ont postés. Nous n’en sommes pas responsables.