Fix _make_tags.sh

Redirection didn’t work as intended with sh. It now correctly generates
tag files
This commit is contained in:
Gergely Polonkai 2015-08-19 10:41:24 +00:00
parent 71aef8e93e
commit c24677caae

View File

@ -7,12 +7,14 @@
layout="posts-by-tag" layout="posts-by-tag"
for tag in `grep -h ^tags: _posts/* | sed -e 's/^tags: \[//' -e 's/\]$//' -e 's/, /\n/g' | sort | uniq` for tag in `grep -h ^tags: _posts/* | sed -re 's/^tags: +\[//' -e 's/\]$//' -e 's/, /\n/g' | sort | uniq`
do do
tag_file="blog/tag/${tag}.html" tag_file="blog/tag/${tag}.html"
if [ ! -f $tag_file ] if [ ! -f $tag_file ]
then then
echo "Creating $tag_file"
cat <<EOF > $tag_file cat <<EOF > $tag_file
--- ---
layout: $layout layout: $layout
@ -20,12 +22,12 @@ tag: $tag
--- ---
EOF EOF
else else
if ! grep "^tag: ${tag}$" $tag_file &> /dev/null if ! egrep "^tag: +${tag}$" $tag_file 2>&1 > /dev/null
then then
sed -i "0,/---/! s/---/tag: $tag\\n---/" $tag_file sed -i "0,/---/! s/---/tag: $tag\\n---/" $tag_file
fi fi
if ! grep "^layout: " $tag_file &> /dev/null if ! egrep "^layout: +" $tag_file 2>&1 > /dev/null
then then
sed -i "0,/---/! s/---/layout: $layout\\n---/" $tag_file sed -i "0,/---/! s/---/layout: $layout\\n---/" $tag_file
fi fi