Skip to content

Commit

Permalink
nixos/networking: fix shellcheck findings with enableStrictShellCheck…
Browse files Browse the repository at this point in the history
…s enabled

Signed-off-by: Sefa Eyeoglu <[email protected]>
  • Loading branch information
Scrumplex committed Oct 18, 2024
1 parent b792bab commit 8e6cc2f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions nixos/modules/tasks/network-interfaces-scripted.nix
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ let
script =
''
state="/run/nixos/network/addresses/${i.name}"
mkdir -p $(dirname "$state")
mkdir -p "$(dirname "$state")"
ip link set dev "${i.name}" up
Expand All @@ -206,14 +206,14 @@ let
if out=$(ip addr replace "${cidr}" dev "${i.name}" 2>&1); then
echo "done"
else
echo "'ip addr replace "${cidr}" dev "${i.name}"' failed: $out"
echo "'ip addr replace \"${cidr}\" dev \"${i.name}\"' failed: $out"
exit 1
fi
''
)}
state="/run/nixos/network/routes/${i.name}"
mkdir -p $(dirname "$state")
mkdir -p "$(dirname "$state")"
${flip concatMapStrings (i.ipv4.routes ++ i.ipv6.routes) (route:
let
Expand All @@ -228,7 +228,7 @@ let
if out=$(ip route add ${type} "${cidr}" ${options} ${via} dev "${i.name}" proto static 2>&1); then
echo "done"
elif ! echo "$out" | grep "File exists" >/dev/null 2>&1; then
echo "'ip route add ${type} "${cidr}" ${options} ${via} dev "${i.name}"' failed: $out"
echo "'ip route add ${type} \"${cidr}\" ${options} ${via} dev \"${i.name}\"' failed: $out"
exit 1
fi
''
Expand All @@ -237,7 +237,7 @@ let
preStop = ''
state="/run/nixos/network/routes/${i.name}"
if [ -e "$state" ]; then
while read cidr; do
while read -r cidr; do
echo -n "deleting route $cidr... "
ip route del "$cidr" dev "${i.name}" >/dev/null 2>&1 && echo "done" || echo "failed"
done < "$state"
Expand All @@ -246,7 +246,7 @@ let
state="/run/nixos/network/addresses/${i.name}"
if [ -e "$state" ]; then
while read cidr; do
while read -r cidr; do
echo -n "deleting address $cidr... "
ip addr del "$cidr" dev "${i.name}" >/dev/null 2>&1 && echo "done" || echo "failed"
done < "$state"
Expand Down

0 comments on commit 8e6cc2f

Please sign in to comment.