Ver código fonte

package/mdnsd/S50mdnsd: do not clobber exit code

As pointed out by shellcheck, the exit code of the start/stop/restart/reload
command is clobbered by the 'echo "FAIL'" statement:

In package/mdnsd/S50mdnsd line 52:
exit $?
     ^-- SC2320 (warning): This $? refers to echo/printf, not a previous command. Assign to variable to avoid it being overwritten.

So introduce a $status variable to keep track of it, similar to how it is
done in S40iwd.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Peter Korsgaard 6 meses atrás
pai
commit
be20c12e15
1 arquivos alterados com 4 adições e 2 exclusões
  1. 4 2
      package/mdnsd/S50mdnsd

+ 4 - 2
package/mdnsd/S50mdnsd

@@ -37,7 +37,9 @@ reload() {
 
 case "$1" in
 	start|stop|restart|reload)
-		if "$1"; then
+		"$1"
+		status=$?
+		if [ "$status" -eq 0 ]; then
 			echo "OK"
 		else
 			echo "FAIL"
@@ -49,4 +51,4 @@ case "$1" in
 		;;
 esac
 
-exit $?
+exit "$status"