3 ms·
What shell are you using here? In bash, I would run something like: for f in ./posts/*.md; do dst=site/${f%.md}.html cat head.html >$dst
by mjlee 3y ago
What shell are you using here? In bash, I would run something like:
for f in ./posts/*.md; do
dst=site/${f%.md}.html
cat head.html >$dst
markdown $f >>$dst
cat footer.html >>$dst
done
- zkldi 3y agoboth of these scripts break on perfectly valid filenames with whitespace, it's pretty rough how shell scripting directs you towards writing subtly broken scripts.
- arp242 3y agoIt's not broken in zsh.
- KolenCh 3y agoPerfectly valid file names in your case can be quite poor choice of names in the context of generating static site. And even if the code could be perfectly runnable, I expect them to be pseudo-code here to illustrate a point, not to ask people to run it.
- arp242 3y agoOops, the :r to remove the extension is zsh; I'm so used to writing scripts in it I sometimes forget translating it to sh/bash (should also quote the variables in (ba)?sh).