Skip to content

Commit

Permalink
fix(rules): Use tail instead of head to not truncate pipeline
Browse files Browse the repository at this point in the history
Using `head` with a long document can kill off the read operation before
the rest of the pipeline is done leaving `m4` to throw an error message.
By using `tac` and `tail` instead we force the pipeline to stay open.

Another option would have been `sed -n -e '1,$(HEAD)p'`, but that
doesn't use the same number syntax to allow for "all but X lines" usage.
  • Loading branch information
alerque committed Nov 7, 2024
1 parent 840cbd5 commit aa4c4a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rules/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ BRANCH := $(subst refs/heads/,,$(or $(CI_COMMIT_REF_NAME),$(GITHUB_HEAD_REF),$(G
TAG := $(or $(CI_COMMIT_TAG),$(shell $(_ENV) $(GIT) describe --tags --exact-match 2>/dev/null))
ALLTAGS := $(strip $(CI_COMMIT_TAG) $(shell $(_ENV) $(GIT) tag --points-at HEAD | $(XARGS) echo))
PARENT := $(shell $(_ENV) $(GIT) merge-base $(or $(CI_MERGE_REQUEST_SOURCE_BRANCH_NAME),$(GITHUB_BASE_REF),master) $(BRANCH) 2>/dev/null)
HEAD ?=
HEAD ?= +0

# Add mock-ups to sources
ifeq ($(strip $(MOCKUPS)),true)
Expand Down Expand Up @@ -556,7 +556,7 @@ $(BUILDDIR)/%-$(_flattened).md: %.md $$(shell $(_ENV) list_related_files.zsh mds
$(M4) $(filter %.m4,$^) =($(SED) -s -e '$${p;g;}' $(or $(filter %.md,$(wordlist 2,9999,$^)),$<))
fi |
renumber_footnotes.pl |
$(and $(HEAD),head -n$(HEAD) |) \
tac | tail --lines=$(HEAD) | tac |
$(pandoc_bug_1385) |
$(PANDOC) $(PANDOCARGS) $(PANDOCNORMALIZEARGS) > $@

Expand Down Expand Up @@ -1220,7 +1220,7 @@ repository-worklog.pdf: $(BUILDDIR)/repository-worklog.md
$< -o $@

$(BUILDDIR)/%-$(_verses).json: $(BUILDDIR)/%-$(_processed).md
$(if $(HEAD),head -n$(HEAD),cat) $< |
tac $< | tail --lines=$(HEAD) | tac |
extract_references.js > $@

$(BUILDDIR)/%-$(_verses)-$(_sorted).json: $(BUILDDIR)/%-$(_verses).json
Expand Down

0 comments on commit aa4c4a3

Please sign in to comment.