* support/check_forensic: Fix temp file usage
Submitted By: Javier Fernandez-Sanguino Pen~a
Reviewed By: Thom May
* support/check_forensic: Fix script on platforms that do not have either
mktemp or tempfile (such as Solaris).
Also tested on Darwin & FreeBSD.
Submitted by: jerenkrantz
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.0.x@371622
13f79535-47bb-0310-9956-
ffa450edef68
-*- coding: utf-8 -*-
Changes with Apache 2.0.56
+ *) support/check_forensic: Fix temp file usage
+ [Javier Fernandez-Sanguino Pen~a <jfs computer.org>]
+
*) Chunk filter: Fix chunk filter to create correct chunks in the case that
a flush bucket is surrounded by data buckets. [Ruediger Pluem]
nd: I'm going to reverse the default
jerenkrantz, striker: I'm confused as to the status of this backport.
- *) support/check_forensic: Fix tempfile usage
- svn rev 125495, 126224
- jerenkrantz says: r126224 fixes brokenness with r125495 on Solaris.
- +1: thommay, jerenkrantz, trawick
- trawick: "which" isn't portable; I've suggested a work-around on dev@
- (not standing in way of backport)
- jorton said: NetBSD's which isn't sufficient either.
- jerenkrantz: Since it's not in the critical path (and depends on
- mod_log_forensic), I think it's still worth it to backport
- it as-is. For the one or two platforms that don't like
- which, they can write their own version of the script.
- (jorton agrees)
-
*) Win32: Move call to mpm_service_install to the rewrite_args hook
from the post_config hook.
http://svn.apache.org/viewcvs?view=rev&rev=154319
F=$1
-cut -f 1 -d '|' $F > /tmp/fc-all.$$
-grep + < /tmp/fc-all.$$ | cut -c2- | sort > /tmp/fc-in.$$
-grep -- - < /tmp/fc-all.$$ | cut -c2- | sort > /tmp/fc-out.$$
+temp_create_method=file
+if test -f `which mktemp`; then
+ temp_create_method=mktemp
+elif test -f `which tempfile`; then
+ temp_create_method=tempfile
+fi
+
+create_temp()
+{
+ prefix=$1
+ case "$temp_create_method" in
+ file)
+ name="/tmp/$1.$$"
+ ;;
+ mktemp)
+ name=`mktemp -t $1.XXXXXX`
+ ;;
+ tempfile)
+ name=`tempfile --prefix=$1`
+ ;;
+ *)
+ echo "$0: Cannot create temporary file"
+ exit 1
+ ;;
+ esac
+}
+
+create_temp fcall
+all=$name
+create_temp fcin
+in=$name
+create_temp fcout
+out=$name
+trap "rm -f -- \"$all\" \"$in\" \"$out\";" 0 1 2 3 13 15
+
+cut -f 1 -d '|' $F > $all
+grep + < $all | cut -c2- | sort > $in
+grep -- - < $all | cut -c2- | sort > $out
+
# use -i instead of -I for GNU xargs
-join -v 1 /tmp/fc-in.$$ /tmp/fc-out.$$ | xargs -I xx egrep "^\\+xx" $F
-rm /tmp/fc-all.$$ /tmp/fc-in.$$ /tmp/fc-out.$$
+join -v 1 $in $out | xargs -I xx egrep "^\\+xx" $F
+exit 0