From 7b310c8076eaccd9bce5366cd80933be7e948e11 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Mon, 5 Feb 2024 17:47:31 +0000 Subject: [PATCH] bin: Add POSIX shell linter and ensure scripts are compliant --- .gitlab-ci.yml | 12 ++++++++++++ bin/startplasmamobile-dev.sh.cmake | 8 ++++---- bin/startplasmamobile.in | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 735ffe13..9325d627 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,3 +6,15 @@ include: file: - /gitlab-templates/reuse-lint.yml - /gitlab-templates/linux-qt6.yml + +posix-script-compliance: + image: + name: debian:latest + entrypoint: [""] + stage: build + script: + - apt-get update + - apt-get -y install shellcheck + - shellcheck -x -s sh bin/startplasmamobile.in + - shellcheck -x -s sh bin/startplasmamobile.in + - shellcheck -x --exclude=1091 -s sh bin/startplasmamobile-dev.sh.cmake # ignore error from file not existing (given by cmake) diff --git a/bin/startplasmamobile-dev.sh.cmake b/bin/startplasmamobile-dev.sh.cmake index 5011ed10..ee1c25f8 100755 --- a/bin/startplasmamobile-dev.sh.cmake +++ b/bin/startplasmamobile-dev.sh.cmake @@ -3,17 +3,17 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -source @CMAKE_INSTALL_FULL_LIBEXECDIR@/plasma-dev-prefix.sh +. "@CMAKE_INSTALL_FULL_LIBEXECDIR@/plasma-dev-prefix.sh" # This is a bit of a hack done because systemd starts in pam, and we only set our dev paths after all that is complete # This copies everything into a transient runtime directory that systemd reads and reloads the units -if [ ! -z "$XDG_RUNTIME_DIR" ]; then +if [ -n "$XDG_RUNTIME_DIR" ]; then mkdir -p "$XDG_RUNTIME_DIR/systemd/user.control" - command cp -r @KDE_INSTALL_FULL_SYSTEMDUSERUNITDIR@/* $XDG_RUNTIME_DIR/systemd/user.control + cp -r @KDE_INSTALL_FULL_SYSTEMDUSERUNITDIR@/* "$XDG_RUNTIME_DIR"/systemd/user.control systemctl --user daemon-reload fi -startplasmamobile$@ +startplasmamobile "$@" diff --git a/bin/startplasmamobile.in b/bin/startplasmamobile.in index f2154683..12af661a 100755 --- a/bin/startplasmamobile.in +++ b/bin/startplasmamobile.in @@ -18,7 +18,7 @@ export PLASMA_INTEGRATION_USE_PORTAL=1 export PLASMA_PLATFORM=phone:handset # if coredumpd knows about the dumps, make sure drkonqi catches them -if [[ $(cat /proc/sys/kernel/core_pattern) =~ /systemd-coredump ]] +if grep -q '/systemd-coredump' /proc/sys/kernel/core_pattern then export KDE_COREDUMP_NOTIFY=1 fi