From 8fe4a3bc2adbc18c68850101048ba51f081c02d1 Mon Sep 17 00:00:00 2001 From: Miles Goodhew Date: Wed, 25 Jan 2023 23:12:04 +1100 Subject: [PATCH] Addressed whines from "shellcheck -s sh" --- edit-options.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/edit-options.sh b/edit-options.sh index 58a3edd..83c7f7d 100755 --- a/edit-options.sh +++ b/edit-options.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Purpose: Make it easier to edit the driver options file. # @@ -28,7 +28,7 @@ SCRIPT_VERSION="20230120" OPTIONS_FILE="8821cu.conf" DEFAULT_EDITOR="$(cat default-editor.txt)" -if [[ $EUID -ne 0 ]]; then +if [ "$(id -u)" -ne 0 ]; then echo "You must run this script with superuser (root) privileges." echo "Try: \"sudo ./${SCRIPT_NAME}\"" exit 1 @@ -47,11 +47,15 @@ if ! command -v "${TEXT_EDITOR}" >/dev/null 2>&1; then exit 1 fi +# displays script name and version +echo ": ${SCRIPT_NAME} v${SCRIPT_VERSION}" + ${TEXT_EDITOR} /etc/modprobe.d/${OPTIONS_FILE} -read -p "Do you want to apply the new options by rebooting now? [y/N] " -n 1 -r +echo "Do you want to apply the new options by rebooting now? [y/N] " +read -r REPLY echo # move to a new line -if [[ $REPLY =~ ^[Yy]$ ]]; then +if [ "${REPLY}" = y ] || [ "${REPLY}" = Y ]; then reboot fi