From 7efaa33b0cbbd28684801fe17fe99aad213825e1 Mon Sep 17 00:00:00 2001 From: Gulshan Singh Date: Sat, 22 Oct 2022 16:33:00 -0700 Subject: [PATCH] Install shfmt on Ubuntu 22.04, otherwise skip running linter (#1323) --- .github/workflows/lint.yml | 1 - lint.sh | 8 ++++++-- setup-dev.sh | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9d6720141..d51502af2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,6 @@ jobs: run: | ./setup.sh --user ./setup-dev.sh --user - sudo snap install shfmt - name: Run linters run: | diff --git a/lint.sh b/lint.sh index f03dace2c..3025e6879 100755 --- a/lint.sh +++ b/lint.sh @@ -49,8 +49,12 @@ fi flake8 --show-source ${LINT_FILES} -# Indents are four spaces, binary ops can start a line, and indent switch cases -shfmt -i 4 -bn -ci -d . +if [ -x "$(command -v shfmt)" ]; then + # Indents are four spaces, binary ops can start a line, and indent switch cases + shfmt -i 4 -bn -ci -d . +else + echo "shfmt not installed, skipping" +fi # Checking minimum python version vermin -q -t=3.6 --violations ./pwndbg/ diff --git a/setup-dev.sh b/setup-dev.sh index 4641a0936..71ab94d11 100755 --- a/setup-dev.sh +++ b/setup-dev.sh @@ -34,6 +34,11 @@ install_apt() { curl \ build-essential \ gdb + + if [[ "$1" == "22.04" ]]; then + sudo apt install shfmt + fi + test -f /usr/bin/go || sudo apt-ge\t install -y golang # Install zig to current directory @@ -57,11 +62,18 @@ install_apt() { } if linux; then - distro=$(grep "^ID=" /etc/os-release | cut -d'=' -f2 | sed -e 's/"//g') + distro=$( + . /etc/os-release + echo ${ID} + ) case $distro in "ubuntu") - install_apt + ubuntu_version=$( + . /etc/os-release + echo ${VERSION_ID} + ) + install_apt $ubuntu_version ;; *) # we can add more install command for each distros. echo "\"$distro\" is not supported distro. Will search for 'apt' or 'dnf' package managers."