Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: fix shellcheck for misc/systemv/nix-daemon #11103

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
++ [
pkgs.buildPackages.cmake
pkgs.shellcheck
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to run shellcheck myself manually.

Shellcheck has a diff output style that you can try to apply for auto fixes for lots of cases now
shellcheck misc/systemv/nix-daemon -f diff | git apply

modular.pre-commit.settings.package
(pkgs.writeScriptBin "pre-commit-hooks-install"
modular.pre-commit.settings.installationScript)
Expand Down
1 change: 0 additions & 1 deletion maintainers/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@
excludes = [
# We haven't linted these files yet
''^config/install-sh$''
''^misc/systemv/nix-daemon$''
''^misc/bash/completion\.sh$''
''^misc/fish/completion\.fish$''
''^misc/zsh/completion\.zsh$''
Expand Down
17 changes: 12 additions & 5 deletions misc/systemv/nix-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,28 @@ else
fi

# Source function library.
# shellcheck source=/dev/null
. /etc/init.d/functions

LOCKFILE=/var/lock/subsys/nix-daemon
RUNDIR=/var/run/nix
PIDFILE=${RUNDIR}/nix-daemon.pid
RETVAL=0

base=${0##*/}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning from shellcheck that this has no reference.

# https://www.shellcheck.net/wiki/SC3004
# Check if gettext exists
if ! type gettext > /dev/null 2>&1
then
# If not, create a dummy function that returns the input verbatim
gettext() { printf '%s' "$1"; }
fi

start() {

mkdir -p ${RUNDIR}
chown ${NIX_DAEMON_USER}:${NIX_DAEMON_USER} ${RUNDIR}

echo -n $"Starting nix daemon... "
printf '%s' "$(gettext 'Starting nix daemon... ')"

daemonize -u $NIX_DAEMON_USER -p ${PIDFILE} $NIX_DAEMON_BIN $NIX_DAEMON_OPTS
RETVAL=$?
Expand All @@ -58,7 +65,7 @@ start() {
}

stop() {
echo -n $"Shutting down nix daemon: "
printf '%s' "$(gettext 'Shutting down nix daemon: ')"
killproc -p ${PIDFILE} $NIX_DAEMON_BIN
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
Expand All @@ -67,7 +74,7 @@ stop() {
}

reload() {
echo -n $"Reloading nix daemon... "
printf '%s' "$(gettext 'Reloading nix daemon... ')"
killproc -p ${PIDFILE} $NIX_DAEMON_BIN -HUP
RETVAL=$?
echo
Expand Down Expand Up @@ -105,7 +112,7 @@ case "$1" in
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
printf '%s' "$(gettext "Usage: $0 {start|stop|status|restart|condrestart}")"
exit 2
;;
esac
Expand Down
Loading