diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a5fcda1db730b4e2b0f1fd7e9318c98261017d85..35ecccac531d18e624f3f6b3c052025ee2b2e01b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,3 +13,9 @@ repos: name: DWM aux files cleaner language: script entry: hooks/dwm_cleaner.sh + +- repo: git://github.com/detailyang/pre-commit-shell + rev: v1.0.6 + hooks: + - id: shell-lint + exclude: ^dotfiles/ diff --git a/hooks/deps_sort.sh b/hooks/deps_sort.sh index 0d4caed17cc7643efd431ce2fe35517c22e5b241..2ff3836fd2784598e722147b385981aaaebeb81c 100755 --- a/hooks/deps_sort.sh +++ b/hooks/deps_sort.sh @@ -4,7 +4,6 @@ set -e check_files() { local all_files=( "$@" ) - has_error=0 for file in "${all_files[@]}" ; do if [[ -f "$file" ]]; then sort -o "$file" "$file" diff --git a/install.sh b/install.sh index 629b9032e39a325ec626e625fbf4ccedb61411ed..40aa7c0a29349ec2bff733b1f69b06d31992a5c1 100644 --- a/install.sh +++ b/install.sh @@ -1,17 +1,17 @@ #!/bin/bash function cleanup(){ - rm -rfv $(find -name "build_*" -type d) + rm -rfv "$(find . -name "build_*" -type d)" } function build_from_git(){ build_dir="$(mktemp -d build_XXXX)" - pushd "$build_dir" - git clone $1 repo - pushd repo + pushd "$build_dir" || exit + git clone "$1" repo + pushd repo || exit eval "$2" - popd - popd + popd || exit + popd || exit } function build_libs_from_sources(){ @@ -23,7 +23,7 @@ function build_libs_from_sources(){ function update_firefox_profile(){ firefox_dir="$HOME/.mozilla/firefox" - fire_profile="$(grep Default $firefox_dir/installs.ini | cut -d '=' -f2)" + fire_profile="$(grep Default "$firefox_dir"/installs.ini | cut -d '=' -f2)" cp -v ./dotfiles/firefox/user.js "$firefox_dir/$fire_profile" mkdir -vp "$firefox_dir/$fire_profile/chrome" cp -v ./dotfiles/firefox/userChrome.css "$firefox_dir/$fire_profile/chrome" @@ -50,7 +50,9 @@ function enable_services(){ } function main(){ + # shellcheck disable=SC2046 sudo pacman -Syu --needed $(cat ./pacman.deps) + # shellcheck disable=SC2046 pikaur -Syu --needed --noconfirm --noedit $(cat ./pikaur.deps) update_firefox_profile build_libs_from_sources diff --git a/pacman.deps b/pacman.deps index 23ec2f64cdfe27718d5331b134fa5a5d1d374dde..79b6d5a3b79450c2b8220a5c99374b13cbf735e5 100644 --- a/pacman.deps +++ b/pacman.deps @@ -12,6 +12,7 @@ picom playerctl pygobject-devel ranger +shellcheck ttf-fira-code ttf-font-awesome ttf-ubuntu-font-family diff --git a/update_desktop.sh b/update_desktop.sh index 7e9570d0f55212c126218609e145f2249b67bb3f..e06157f326c689542f4fd5ad22486c7721167371 100644 --- a/update_desktop.sh +++ b/update_desktop.sh @@ -20,9 +20,9 @@ function full_update(){ } function apply_patch(){ - patch_name="$(basename $1 | cut -d '.' -f1)" + patch_name="$(basename "$1" | cut -d '.' -f1)" patch_path="$(readlink -f "$1")" - pushd "{{dwm_dir}}" + pushd "{{dwm_dir}}" || exit git checkout -b "patch/$patch_name" patch < "$patch_path" git add . @@ -59,35 +59,37 @@ function main(){ done if [[ show_help -eq 1 ]];then - pushd "{{dwm_dir}}" + pushd "{{dwm_dir}}" || exit show_help exit 0 fi if [[ -n "$patch_to_apply" ]];then apply_patch "$patch_to_apply" - popd + popd || exit if [[ $((full_update + local_update)) -eq 0 ]];then exit 0 fi fi + pushd "{{dwm_dir}}" || exit if [[ full_update -eq 1 ]];then - pushd "{{dwm_dir}}" full_update exit 0 fi if [[ local_update -eq 1 ]];then - pushd "{{dwm_dir}}" local_update exit 0 fi - pushd "{{dwm_dir}}" show_help exit 0 } -trap popd EXIT +function go_back(){ + popd || exit +} + +trap go_back EXIT main "$@"