[PATCH] Makefile: Simplify error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of having to write '|| exit $$?' all the time,
use the shell's '-Eeuo pipefail' options, which handle
errors even better.  However, pipefail needs bash,
so POSIX sh (default) is not valid.

Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>
---

Hi Michael,

I'm not sure how much POSIX sh compatibility is needed for the man pages
Makefile.  There are probably projects out there that don't have bash,
and still want to use it.  So maybe we should't apply this.  I don't know.
Up to you.

Thanks,

Alex


 Makefile | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index fdfaf9645..4df4f5846 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
 #!/usr/bin/make -f
+SHELL = /bin/bash -Eeuo pipefail
 
 # Do not print "Entering directory ..."
 MAKEFLAGS += --no-print-directory
@@ -33,15 +34,14 @@ html: | builddirs-html
 	|while read f; do \
 		man2html $(HTOPTS) "$$f" \
 		|sed -e '1,2d' \
-		>"$(htmlbuilddir)/$${f}$(htmlext)" \
-			|| exit $$?; \
+		>"$(htmlbuilddir)/$${f}$(htmlext)"; \
 	done;
 
 .PHONY: builddirs-html
 builddirs-html:
 	find man?/ -type d \
 	|while read d; do \
-		$(INSTALL_DIR) "$(htmlbuilddir)/$$d" || exit $$?; \
+		$(INSTALL_DIR) "$(htmlbuilddir)/$$d"; \
 	done;
 
 .PHONY: install-html
@@ -49,57 +49,57 @@ install-html: | installdirs-html
 	cd $(htmlbuilddir) && \
 	find man?/ -type f \
 	|while read f; do \
-		$(INSTALL_DATA) -T "$$f" "$(DESTDIR)$(htmldir_)/$$f" || exit $$?; \
+		$(INSTALL_DATA) -T "$$f" "$(DESTDIR)$(htmldir_)/$$f"; \
 	done;
 
 .PHONY: installdirs-html
 installdirs-html:
 	find man?/ -type d \
 	|while read d; do \
-		$(INSTALL_DIR) "$(DESTDIR)$(htmldir_)/$$d" || exit $$?; \
+		$(INSTALL_DIR) "$(DESTDIR)$(htmldir_)/$$d"; \
 	done;
 
 .PHONY: install
 install: | installdirs
 	find man?/ -type f \
 	|while read f; do \
-		$(INSTALL_DATA) -T "$$f" "$(DESTDIR)$(mandir)/$$f" || exit $$?; \
+		$(INSTALL_DATA) -T "$$f" "$(DESTDIR)$(mandir)/$$f"; \
 	done;
 
 .PHONY: installdirs
 installdirs:
 	find man?/ -type d \
 	|while read d; do \
-		$(INSTALL_DIR) "$(DESTDIR)$(mandir)/$$d" || exit $$?; \
+		$(INSTALL_DIR) "$(DESTDIR)$(mandir)/$$d"; \
 	done;
 
 .PHONY: uninstall remove
 uninstall remove:
 	find man?/ -type f \
 	|while read f; do \
-		rm -f "$(DESTDIR)$(mandir)/$$f" || exit $$?; \
-		rm -f "$(DESTDIR)$(mandir)/$$f".* || exit $$?; \
+		rm -f "$(DESTDIR)$(mandir)/$$f"; \
+		rm -f "$(DESTDIR)$(mandir)/$$f".*; \
 	done;
 
 .PHONY: uninstall-html
 uninstall-html:
 	find man?/ -type f \
 	|while read f; do \
-		rm -f "$(DESTDIR)$(htmldir_)/$$f".* || exit $$?; \
+		rm -f "$(DESTDIR)$(htmldir_)/$$f".*; \
 	done;
 
 .PHONY: clean
 clean:
 	find man?/ -type f \
 	|while read f; do \
-		rm -f "$(htmlbuilddir)/$$f".* || exit $$?; \
+		rm -f "$(htmlbuilddir)/$$f".*; \
 	done;
 
 # Check if groff reports warnings (may be words of sentences not displayed)
 # from https://lintian.debian.org/tags/groff-message.html
 .PHONY: check-groff-warnings
 check-groff-warnings:
-	GROFF_LOG="$$(mktemp --tmpdir manpages-checksXXXX)" || exit $$?; \
+	GROFF_LOG="$$(mktemp --tmpdir manpages-checksXXXX)"; \
 	for i in man?/*.[1-9]; \
 	do \
 		if grep -q 'SH.*NAME' "$$i"; then \
-- 
2.31.1




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux