Score:0

Bash can't read glob pattern

ie flag

I'm trying to make my CV build script run on Ubuntu. I usually use Fedora to build it. Each page is written in SVG, I use Inkscape to generate PDF and then pdfmerge to join those pages into one.

On Ubuntu I can't find pdfmerge so I wanted to change it to pdfunite. But it seems the command doesn't accept the glob patterns. It should be handled by the shell:

pdfunite pl/jakub-jankiewicz-cv-page{1,2,3}.pdf jakub-jankiewicz-cv-pl.pdf
I/O Error: Couldn't open file 'pl/jakub-jankiewicz-cv-page{1,2,3}.pdf': No such file or directory.
Syntax Error: Could not merge damaged documents ('pl/jakub-jankiewicz-cv-page{1,2,3}.pdf')
make: *** [Makefile:22: jakub-jankiewicz-cv-pl.pdf] Błąd 255

This is the code I have in my Makefile:

jakub-jankiewicz-cv-pl.pdf: pl/jakub-jankiewicz-cv-page1.pdf pl/jakub-jankiewicz-cv-page2.pdf pl/jakub-jankiewicz-cv-page3.pdf
    pdfunite pl/jakub-jankiewicz-cv-page{1,2,3}.pdf jakub-jankiewicz-cv-pl.pdf

Why I can't use a glob pattern like {1,2,3} on Ubuntu? I have Xubuntu 22.04 and bash 5.1.16(1)-release the same code works fine on Fedora.

Raffa avatar
jp flag
Don't run it from a Makefile ... Run it in the terminal directly `pdfunite pl/jakub-jankiewicz-cv-page{1,2,3}.pdf jakub-jankiewicz-cv-pl.pdf` and the pattern should be expanded.
jcubic avatar
ie flag
@Raffa yes, running directly works but I want to use Makefile.
Score:6
hr flag

{1,2,3} isn't a glob pattern - it's a brace expansion. Likely the issue is not that "bash can't read" it - it's that the make command uses the POSIX /bin/sh shell by default, which on Ubuntu is symbolically linked to /bin/dash rather than /bin/bash. Your options are either:

  1. change the brace expansion to an actual (POSIX compliant) glob - for a single digit, that's straightforward i.e. pl/jakub-jankiewicz-cv-page[123].pdf

  2. change the shell in your Makefile to bash, by adding SHELL := /bin/bash

See also Bash is abnormal in Makefile!.

jcubic avatar
ie flag
I would never figure this out. Thanks.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.