From 006260555956124bf11997e59dca4ee9e1351841 Mon Sep 17 00:00:00 2001 From: Leif Walsh Date: Sun, 24 Jul 2011 20:27:07 +0200 Subject: Changing mktemp calls and some two sed calls to make it work with BSD coreutils (and still GNU coreutils valid) --- build.sh | 5 +++-- html-gen.sh | 36 +++++++++++++++++++----------------- post-receive.sh | 8 ++++---- pre-commit.sh | 2 +- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/build.sh b/build.sh index 854aeb6..172c086 100755 --- a/build.sh +++ b/build.sh @@ -2,11 +2,12 @@ include_file() { f=`echo -n $2 | sed 's/\//\\\\\//g'` - tmp=`mktemp` + tmp=`mktemp fugitiveXXXXXX` cat "$2" | gzip | base64 > "$tmp" cat "$1" | sed "/#INCLUDE:$f#/ { r $tmp - d }" + d + }" rm "$tmp" } diff --git a/html-gen.sh b/html-gen.sh index d96cc38..21ed5ee 100644 --- a/html-gen.sh +++ b/html-gen.sh @@ -16,9 +16,8 @@ if [ "$tpl_change" -gt 0 ]; then modified_files=`git log $first..HEAD^ --name-status --pretty="format:" | \ grep -E '^A' | cut -f2 | sort | uniq` deleted_files= - tmpart=`mktemp` - tmpmod=`mktemp` - tmpadd=`mktemp` + tmpart=`mktemp fugitiveXXXXXX` + tmpmod=`mktemp fugitiveXXXXXX` ls "$articles_dir"/* > "$tmpart" echo "$modified_files" | tr " " "\n" > "$tmpmod" modified_files=`comm -12 --nocheck-order "$tmpmod" "$tmpart"` @@ -26,9 +25,9 @@ if [ "$tpl_change" -gt 0 ]; then echo "[fugitive] Templates changed, regenerating everything..." fi -generated_files=`mktemp` +generated_files=`mktemp fugitiveXXXXXX` -articles_sorted=`mktemp` +articles_sorted=`mktemp fugitiveXXXXXX` for f in "$articles_dir"/*; do ts=`git log --format="%at" -- "$f" | tail -1` if [ "$ts" != "" ]; then @@ -40,7 +39,7 @@ if [ "`head -1 $articles_sorted`" = "" ]; then echo "[fugitive] WARNING: there's no article, errors may occur." >&2 fi -articles_sorted_with_delete=`mktemp` +articles_sorted_with_delete=`mktemp fugitiveXXXXXX` for f in "$articles_dir"/* $deleted_files; do ts=`git log --format="%at" -- "$f" | tail -1` if [ "$ts" != "" ]; then @@ -48,7 +47,7 @@ for f in "$articles_dir"/* $deleted_files; do fi done | sort -k1,1nr | cut -d' ' -f2 > "$articles_sorted_with_delete" -commits=`mktemp` +commits=`mktemp fugitiveXXXXXX` git log --oneline | cut -d' ' -f1 > "$commits" get_article_info() { @@ -84,7 +83,7 @@ get_article_title() { fi } get_article_content() { - tmp=`mktemp` + tmp=`mktemp fugitiveXXXXXX` tail -n+2 "$articles_dir/$1" > "$tmp" echo "$tmp" } @@ -93,10 +92,12 @@ get_commit_info() { git show -s --format="$1" "$2" } get_commit_body() { - tmp=`mktemp` + tmp=`mktemp fugitiveXXXXXX` git show -s --format="%b" "$1" > "$tmp" if [ "`cat \"$tmp\" | sed \"/^$/d\" | wc -l`" != "0" ]; then echo "$tmp" + else + rm "$tmp" fi } @@ -138,8 +139,8 @@ replace_file() { } replace_includes() { - buf=`mktemp` - buf2=`mktemp` + buf=`mktemp fugitiveXXXXXX` + buf2=`mktemp fugitiveXXXXXX` cat > "$buf" includes=`cat "$buf" | \ sed "s//\n\0\n/g" | \ @@ -151,7 +152,8 @@ replace_includes() { cat "$buf" | \ sed "// { r $inc - d }" > "$buf2" + d + }" > "$buf2" tmpbuf="$buf" buf="$buf2" buf2="$tmpbuf" @@ -260,9 +262,9 @@ replace_empty_article_info() { } replace_foreach () { - foreach_body=`mktemp` - tmpfile=`mktemp` - temp=`mktemp` + foreach_body=`mktemp fugitiveXXXXXX` + tmpfile=`mktemp fugitiveXXXXXX` + temp=`mktemp fugitiveXXXXXX` fe="foreach:$1" cat > "$temp" cat "$temp" | \ @@ -379,9 +381,9 @@ if [ $modification -gt 0 ]; then sed "/^[[:space:]]*$/d" > "$public_dir/archives.html" echo "done." echo -n "[fugitive] Generating $public_dir/feed.xml... " - last_5_articles=`mktemp` + last_5_articles=`mktemp fugitiveXXXXXX` head -5 "$articles_sorted" > "$last_5_articles" - last_5_commits=`mktemp` + last_5_commits=`mktemp fugitiveXXXXXX` head -5 "$commits" > "$last_5_commits" cat "$templates_dir/feed.xml" | \ replace_includes | \ diff --git a/post-receive.sh b/post-receive.sh index 1a40c81..e36d6f5 100644 --- a/post-receive.sh +++ b/post-receive.sh @@ -23,10 +23,10 @@ modified_files=`git log $range --name-status --pretty="format:" | \ deleted_files=`git log $range --name-status --pretty="format:" | \ grep -E '^D' | cut -f2 | sort | uniq` -tmpart=`mktemp` -tmpadd=`mktemp` -tmpmod=`mktemp` -tmpdel=`mktemp` +tmpart=`mktemp fugitiveXXXXXX` +tmpadd=`mktemp fugitiveXXXXXX` +tmpmod=`mktemp fugitiveXXXXXX` +tmpdel=`mktemp fugitiveXXXXXX` ls "$articles_dir"/* > "$tmpart" echo "$added_files" | tr " " "\n" > "$tmpadd" echo "$modified_files" | tr " " "\n" > "$tmpmod" diff --git a/pre-commit.sh b/pre-commit.sh index b070431..ad4ee52 100644 --- a/pre-commit.sh +++ b/pre-commit.sh @@ -2,7 +2,7 @@ articles_dir=`git config --get fugitive.articles-dir` -article_exists=`mktemp` +article_exists=`mktemp fugitiveXXXXXX` for f in "$articles_dir"/*; do ts=`git log --format="%at" -- "$f" | tail -1` if [ "$ts" != "" ]; then -- cgit v1.2.3