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
Fix make succeeding when the recipe fails #135
Conversation
Thanks! I don't think we should be adding For the actual fix, I think the proper solution is to make |
I'd go for this: MANPAGE = grmlzshrc.5
HTMLPAGE = grmlzshrc.html
all: $(MANPAGE) $(HTMLPAGE)
$(MANPAGE)-pre: grmlzshrc.t2t
txt2tags --target man -o$@ $<
$(MANPAGE): $(MANPAGE)-pre
sed -e '/^$$/d' -e 's/^\\e$$//' < $< > $@
$(HTMLPAGE)-pre: grmlzshrc.t2t
txt2tags --target html --style t2t-modern.css -o$@ $<
$(HTMLPAGE): $(HTMLPAGE)-pre
sed -e '/^$$/d' -e 's/^\\$$//' < $< > $@
clean:
rm -f *.5 *.html *.gz *-pre *~
online: all
scp grmlzshrc.html t2t-modern.css grml:/var/www/grml/zsh/
.PHONY: all clean online |
Or maybe this, which is more in line with the previous style: MANPAGES = grmlzshrc.5
HTMLPAGES = grmlzshrc.html
all: $(MANPAGES) $(HTMLPAGES)
.SUFFIXES:
.SUFFIXES: .t2t .5 .html
.t2t.5:
txt2tags --target man -o$@-pre $<
sed -e '/^$$/d' -e 's/^\\e$$//' < $@-pre > $@
.t2t.html:
txt2tags --target html --style t2t-modern.css -o$@-pre $<
sed -e '/^$$/d' -e 's/^\\$$//' < $@-pre > $@
clean:
rm -f *.5 *.html *.gz *-pre *~
online: all
scp grmlzshrc.html t2t-modern.css grml:/var/www/grml/zsh/
.PHONY: all clean online |
Not me! The update I was trying for was kinda ugly; I'm just a hobbyist, about a level up from script kiddie wrt build utils, so thanks @ft for writing those up. I'd of course prefer a maintainer to decide which format to go with; somebody taking over is fine too. If I need to do anything further please tell me. Two things to point out:
- sed -e '/^$$/d' -e 's/^\\$$//' < $@-pre > $@
+ sed -e '/^$$/d' -e 's/^\\$$//' < $@-pre > $@~
+ mv $@~ $@ |
It was, since it makes things more transparent. But I've made a few additions since, that obscure what's going one, so I went back to the
While it's very uncommon for I'd prefer a suffix like MANPAGES = grmlzshrc.5
HTMLPAGES = grmlzshrc.html
all: $(MANPAGES) $(HTMLPAGES)
.SUFFIXES:
.SUFFIXES: .t2t .5 .html
.t2t.5:
@printf 'TXT2TAGS %s\n' "$@"
@txt2tags --quiet --target man -o$@.pre $<
@sed -e '/^$$/d' -e 's/^\\e$$//' < $@.pre > $@.tmp
@rm $@.pre
@mv $@.tmp $@
.t2t.html:
@printf 'TXT2TAGS %s\n' "$@"
@txt2tags --quiet --target html --style t2t-modern.css -o$@.pre $<
@sed -e '/^$$/d' -e 's/^\\$$//' < $@.pre > $@.tmp
@rm $@.pre
@mv $@.tmp $@
clean:
rm -f *.5 *.html *.gz *.pre *.tmp *~
online: all
scp grmlzshrc.html t2t-modern.css grml:/var/www/grml/zsh/
.PHONY: all clean online I can commit this version to |
@ft no objections against committing this to |
Don't worry, I'm not forgetting proper credit. ;) |
In make only timestamps and return values matter. And the shell will create a file and update its timestamp when it sees an output redirection. No matter if the program driving the redirected data fails or not. So even if the first generator run fails, rerunning make will work, with things looking like they worked out just fine. This fixes the issue by running the separate steps toward file generation one by one. This issue was brought up by Edward E. (cbrt64 on github) in PR#135 on github¹, including a proof-of-concept implementation, as well as valuable feedback. This implementation was derived from it. See the pull-request log for details. ¹ #135
Pushed as 4a3593b to master. Closing this PR therefore. Thanks your help! |
Cool beans! Thanks for the attention to detail and the quick turnaround, especially across time zones. One doesn't get that all the time. (pun intended :) |
In make only timestamps and return values matter. And the shell will create a file and update its timestamp when it sees an output redirection. No matter if the program driving the redirected data fails or not. So even if the first generator run fails, rerunning make will work, with things looking like they worked out just fine. This fixes the issue by running the separate steps toward file generation one by one. This issue was brought up by Edward E. (cbrt64 on github) in PR#135 on github¹, including a proof-of-concept implementation, as well as valuable feedback. This implementation was derived from it. See the pull-request log for details. ¹ grml#135
The current
doc/Makefile
has "successfully" created empty man pages on (Arch-ish) MSYS2. See the original issue here.Without a working
txt2tags
, the recipes that generate the grml-zsh-config docs print an error, butmake
succeeds anyway. This is because the error returned to make is from the last tool in the pipeline, regardless of any failing or even absent tools preceding; see here.Also, redirecting a failing command to target (i.e.
> $@
) even without a pipeline is problematic without the GNUish.DELETE_ON_ERROR:
rule, see here (empty build targets are generated, and so will mistakenly succeed on next invocation ofmake
).To mitigate both these case, I went with this approach. These changes could affect portability in ways I'm not aware, if so please advise.