Bash scripts; use double brackets, fix bare variables, add quotes

These scripts explicitly use Bash, so we should be able to use
`[[` instead of `[` (which seems to be recommended).

Also added curly brackets to some bare variables, and quoted some paths.

This makes my IDE a bit more silent :-)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2018-12-22 20:18:33 +01:00
parent d147fe0582
commit 297b30df5f
43 changed files with 143 additions and 144 deletions

View File

@@ -21,13 +21,13 @@ check_dco() {
grep -qE "$dcoRegex"
}
if [ $adds -eq 0 -a $dels -eq 0 ]; then
if [[ ${adds} -eq 0 && ${dels} -eq 0 ]]; then
echo '0 adds, 0 deletions; nothing to validate! :)'
else
commits=( $(validate_log --format='format:%H%n') )
badCommits=()
for commit in "${commits[@]}"; do
if [ -z "$(git log -1 --format='format:' --name-status "$commit")" ]; then
if [[ -z "$(git log -1 --format='format:' --name-status "$commit")" ]]; then
# no content (ie, Merge commit, etc)
continue
fi
@@ -35,7 +35,7 @@ else
badCommits+=( "$commit" )
fi
done
if [ ${#badCommits[@]} -eq 0 ]; then
if [[ ${#badCommits[@]} -eq 0 ]]; then
echo "Congratulations! All commits are properly signed with the DCO!"
else
{