Skip to main content
clarity
Source Link
Seamus
  • 3.8k
  • 2
  • 21
  • 48

I've created a makefile command to automate a publishing workflow using Pandoc and the Generic Preprocessor (GPP). It is as follows:

TODAY = $(shell date +'%Y%m%d-%H%M')
MACROS = utils/gpp/macros.md
TEMPLATE = utils/template.docx

GPP = utils/gpp/gpp.exe
MACROS = utils/gpp/_macros.pp

METADATA = metadata.yaml
FM = content/frontmatter/*.md
MM = content/mainmatter/*.md
CONTENT = $(FM) $(MM)

default: docx

docx:
    for file in $(CONTENT); do \
        fifo=$$(mktemp -u); \
        FIFOS+=("$$fifo"); \
        cat $(MACROS) "$$file" | \
        $(GPP) -DWORD -x -o "$$fifo" & \
    done; \
    pandoc metadata.yaml "$${FIFOS[@]}" -f markdown -t docx \
    --citeproc --csl $(CSL) \
    --reference-doc=$(TEMPLATE) \
    --file-scope \
    -o dist/$(TODAY).docx

It runs fine on the Git terminal on Windows. However on my on Ubuntu 24.04 system, I'm getting a /bin/sh: 1: Syntax error: "(" unexpected error, and it points towards the line for file in $(CONTENT); do \ on Ubuntu 24.04. I've tried the following but to no avail:

  1. for file in ( $(CONTENT) ); do \

  2. for file in "$(CONTENT)"; do \

Why is this happening, and how can I rectify it? (Yes, I'm aware that the GPP link has to be updated for Ubuntu but it doesn't even reach that line)

The repository is public if anyone wants to try it locally: https://github.com/khalid-hussain/editorial-project-template

I've created a makefile command to automate a publishing workflow using Pandoc and the Generic Preprocessor (GPP). It is as follows:

TODAY = $(shell date +'%Y%m%d-%H%M')
MACROS = utils/gpp/macros.md
TEMPLATE = utils/template.docx

GPP = utils/gpp/gpp.exe
MACROS = utils/gpp/_macros.pp

METADATA = metadata.yaml
FM = content/frontmatter/*.md
MM = content/mainmatter/*.md
CONTENT = $(FM) $(MM)

default: docx

docx:
    for file in $(CONTENT); do \
        fifo=$$(mktemp -u); \
        FIFOS+=("$$fifo"); \
        cat $(MACROS) "$$file" | \
        $(GPP) -DWORD -x -o "$$fifo" & \
    done; \
    pandoc metadata.yaml "$${FIFOS[@]}" -f markdown -t docx \
    --citeproc --csl $(CSL) \
    --reference-doc=$(TEMPLATE) \
    --file-scope \
    -o dist/$(TODAY).docx

It runs fine on the Git terminal on Windows. However, I'm getting a /bin/sh: 1: Syntax error: "(" unexpected error and it points towards the line for file in $(CONTENT); do \ on Ubuntu 24.04. I've tried the following but to no avail:

  1. for file in ( $(CONTENT) ); do \

  2. for file in "$(CONTENT)"; do \

Why is this happening and how can I rectify it? (Yes, I'm aware that the GPP link has to be updated for Ubuntu but it doesn't even reach that line)

The repository is public if anyone wants to try it locally: https://github.com/khalid-hussain/editorial-project-template

I've created a makefile command to automate a publishing workflow using Pandoc and the Generic Preprocessor (GPP). It is as follows:

TODAY = $(shell date +'%Y%m%d-%H%M')
MACROS = utils/gpp/macros.md
TEMPLATE = utils/template.docx

GPP = utils/gpp/gpp.exe
MACROS = utils/gpp/_macros.pp

METADATA = metadata.yaml
FM = content/frontmatter/*.md
MM = content/mainmatter/*.md
CONTENT = $(FM) $(MM)

default: docx

docx:
    for file in $(CONTENT); do \
        fifo=$$(mktemp -u); \
        FIFOS+=("$$fifo"); \
        cat $(MACROS) "$$file" | \
        $(GPP) -DWORD -x -o "$$fifo" & \
    done; \
    pandoc metadata.yaml "$${FIFOS[@]}" -f markdown -t docx \
    --citeproc --csl $(CSL) \
    --reference-doc=$(TEMPLATE) \
    --file-scope \
    -o dist/$(TODAY).docx

It runs fine on the Git terminal on Windows. However on my on Ubuntu 24.04 system, I'm getting a /bin/sh: 1: Syntax error: "(" unexpected error, and it points towards the line for file in $(CONTENT); do \. I've tried the following to no avail:

  1. for file in ( $(CONTENT) ); do \

  2. for file in "$(CONTENT)"; do \

Why is this happening, and how can I rectify it? (Yes, I'm aware that the GPP link has to be updated for Ubuntu but it doesn't even reach that line)

The repository is public if anyone wants to try it locally: https://github.com/khalid-hussain/editorial-project-template

Became Hot Network Question
Source Link

Using make variable in bash scripting as part of a makefile command

I've created a makefile command to automate a publishing workflow using Pandoc and the Generic Preprocessor (GPP). It is as follows:

TODAY = $(shell date +'%Y%m%d-%H%M')
MACROS = utils/gpp/macros.md
TEMPLATE = utils/template.docx

GPP = utils/gpp/gpp.exe
MACROS = utils/gpp/_macros.pp

METADATA = metadata.yaml
FM = content/frontmatter/*.md
MM = content/mainmatter/*.md
CONTENT = $(FM) $(MM)

default: docx

docx:
    for file in $(CONTENT); do \
        fifo=$$(mktemp -u); \
        FIFOS+=("$$fifo"); \
        cat $(MACROS) "$$file" | \
        $(GPP) -DWORD -x -o "$$fifo" & \
    done; \
    pandoc metadata.yaml "$${FIFOS[@]}" -f markdown -t docx \
    --citeproc --csl $(CSL) \
    --reference-doc=$(TEMPLATE) \
    --file-scope \
    -o dist/$(TODAY).docx

It runs fine on the Git terminal on Windows. However, I'm getting a /bin/sh: 1: Syntax error: "(" unexpected error and it points towards the line for file in $(CONTENT); do \ on Ubuntu 24.04. I've tried the following but to no avail:

  1. for file in ( $(CONTENT) ); do \

  2. for file in "$(CONTENT)"; do \

Why is this happening and how can I rectify it? (Yes, I'm aware that the GPP link has to be updated for Ubuntu but it doesn't even reach that line)

The repository is public if anyone wants to try it locally: https://github.com/khalid-hussain/editorial-project-template