« Linux : ShellCheck pour analyser vos scripts bash » : différence entre les versions
De www.yakakliker.org
(Page créée avec « == ShellCheck == * Shellcheck est un utilitaire qui va analyser votre script afin de déceler les erreurs. === Installation === <code>apt-get install shellcheck</code> === Analyse d'un script === <code>shellcheck monscript.sh</code> === Exemple de réponse === <syntaxhighlight lang="bash"> In Services.sh line 11: cd ~ ^--^ SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails. Did you mean: cd ~ || exit In Services.sh line 22: cd /h... ») |
Aucun résumé des modifications |
||
(Une version intermédiaire par le même utilisateur non affichée) | |||
Ligne 48 : | Ligne 48 : | ||
== Liens == | == Liens == | ||
https://blog.stephane-robert.info/docs/admin-serveurs/linux/scripts-shell-securises/ | https://blog.stephane-robert.info/docs/admin-serveurs/linux/scripts-shell-securises/ | ||
[[Catégorie:Linux]] | |||
[[Catégorie:Scripts]] | |||
<html> | |||
<a href="https://www.compteurdevisite.com" title="compteur web gratuit sans pub"><img src="https://counter6.optistats.ovh/private/compteurdevisite.php?c=b4epghealnwlf7wuq7gn3ygll9aywrfx" border="0" title="compteur web gratuit sans pub" alt="compteur web gratuit sans pub"></a> | |||
</html> | |||
<html> | |||
<script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script> | |||
<script> | |||
kofiWidgetOverlay.draw('yakakliker', { | |||
'type': 'floating-chat', | |||
'floating-chat.donateButton.text': 'Café', | |||
'floating-chat.donateButton.background-color': '#00b9fe', | |||
'floating-chat.donateButton.text-color': '#fff' | |||
}); | |||
</script> | |||
</html> |
Dernière version du 20 mai 2025 à 11:04
ShellCheck
- Shellcheck est un utilitaire qui va analyser votre script afin de déceler les erreurs.
Installation
apt-get install shellcheck
Analyse d'un script
shellcheck monscript.sh
Exemple de réponse
In Services.sh line 11:
cd ~
^--^ SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
Did you mean:
cd ~ || exit
In Services.sh line 22:
cd /home
^------^ SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
Did you mean:
cd /home || exit
In Services.sh line 24:
echo $env00 >> ~/env.txt
^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
echo "$env00" >> ~/env.txt
In Services.sh line 35:
export var24051101=`date +%y%m%d`
^---------^ SC2155 (warning): Declare and assign separately to avoid masking return values.
^------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
export var24051101=$(date +%y%m%d)
Liens
https://blog.stephane-robert.info/docs/admin-serveurs/linux/scripts-shell-securises/