Bash astuces

15 Linux Bash History Expansion Examples You Should Know

Check syntax avec shellcheck

Voir aussi :

https://github.com/oxsecurity/megalinter

shellcheck monscript.sh

Si faux positif

# shellcheck disable=SC2086 rsync $RSYNC_OPT "${PART}/" "${PART_TMP}/"

$ shellcheck plop.sh In mkiso-debian.sh line 56: source "$FIC_PROPERTIES" ^-- SC1090: Can't follow non-constant source. Use a directive to specify location.

Solution

Ajouter en commentaire shellcheck source=

# shellcheck source=vars/vm-deb10.var source "$FIC_PROPERTIES"

puis

shellcheck -x plop.sh

Avancé

Alternative à eval pour les variablesMeta variables

$ a=1
$ b=2
$ meta_var="a"
$ echo ${!meta_var}
1

Linter

shfmthttps://github.com/mvdan/sh

Auto indentvim

:set expandtab ts=4 sw=4 ai
:retab