Skip to content

Commit bc801e2

Browse files
committed
lint: fix shellcheck for misc/systemv/nix-daemon
Got shellcheck passing for misc/systemv/nix-daemon Not sure how to test this since it's not running on my NixOS machine and I see no references to it in the directory otherwise. See NixOS#10795
1 parent db3e99d commit bc801e2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@
324324
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
325325
++ [
326326
pkgs.buildPackages.cmake
327+
pkgs.shellcheck
327328
modular.pre-commit.settings.package
328329
(pkgs.writeScriptBin "pre-commit-hooks-install"
329330
modular.pre-commit.settings.installationScript)

misc/systemv/nix-daemon

+12-5
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,28 @@ else
3434
fi
3535

3636
# Source function library.
37+
# shellcheck source=/dev/null
3738
. /etc/init.d/functions
3839

3940
LOCKFILE=/var/lock/subsys/nix-daemon
4041
RUNDIR=/var/run/nix
4142
PIDFILE=${RUNDIR}/nix-daemon.pid
4243
RETVAL=0
4344

44-
base=${0##*/}
45+
# https://www.shellcheck.net/wiki/SC3004
46+
# Check if gettext exists
47+
if ! type gettext > /dev/null 2>&1
48+
then
49+
# If not, create a dummy function that returns the input verbatim
50+
gettext() { printf '%s' "$1"; }
51+
fi
4552

4653
start() {
4754

4855
mkdir -p ${RUNDIR}
4956
chown ${NIX_DAEMON_USER}:${NIX_DAEMON_USER} ${RUNDIR}
5057

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

5360
daemonize -u $NIX_DAEMON_USER -p ${PIDFILE} $NIX_DAEMON_BIN $NIX_DAEMON_OPTS
5461
RETVAL=$?
@@ -58,7 +65,7 @@ start() {
5865
}
5966

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

6976
reload() {
70-
echo -n $"Reloading nix daemon... "
77+
printf '%s' "$(gettext 'Reloading nix daemon... ')"
7178
killproc -p ${PIDFILE} $NIX_DAEMON_BIN -HUP
7279
RETVAL=$?
7380
echo
@@ -105,7 +112,7 @@ case "$1" in
105112
fi
106113
;;
107114
*)
108-
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
115+
printf '%s' "$(gettext "Usage: $0 {start|stop|status|restart|condrestart}")"
109116
exit 2
110117
;;
111118
esac

0 commit comments

Comments
 (0)