+78
−0
+52
−0
Loading
Add new dev tool for enforcing proper formatting of the Bash code across the entire repo. This is done in order of defining a common set of good practices to follow when writing .sh|Bash code. As powerful as shfmt may be, it allows only for some specific rules to be enforced, hence it still needs to work side by side with shellcheck syntax-wise. If it comes to style, following rules are being enforced: * indent_style = tab - Lines must be indented with tabs. The exception from this rule is the use of heredocs with <<BASH redirect operator. Spaces can be used to format the line only if it's already preceded with a tab. * binary_next_line = true - Lines can start with logical operators. E.g: if [[ -v foo ]] \ && [[ -v bar ]]; then ... fi * switch_case_indent = true - case|esac patterns are indented with tabs. * space_redirects = true - redirect operators are followed with a space. E.g: > foo over >foo. In addition, shfmt will enforce its own Bash-style for different parts of the code as well. Examples and more details can be found here: https://github.com/mvdan/sh Change-Id: I6e5c8d79e6dba9c6471010f3d0f563dd34e62fd6 Signed-off-by:Michal Berger <michalx.berger@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1418 Reviewed-by:
Karol Latecki <karol.latecki@intel.com> Reviewed-by:
Ben Walker <benjamin.walker@intel.com> Reviewed-by:
Jim Harris <james.r.harris@intel.com> Reviewed-by:
Darek Stojaczyk <dariusz.stojaczyk@intel.com> Community-CI: Mellanox Build Bot Tested-by:
SPDK CI Jenkins <sys_sgci@intel.com>