$OpenBSD: patch-languages_cpp_parser_tool_r++,v 1.1.1.1 2014/07/09 11:30:28 zhuk Exp $
Make it more portable and less error-prone.
--- languages/cpp/parser/tool/r++.orig	Sat Jul 27 20:15:35 2013
+++ languages/cpp/parser/tool/r++	Sat Jul 27 20:22:09 2013
@@ -1,7 +1,6 @@
 #!/bin/sh
 
-me=$(dirname $0)
-CPP="$(which cpp)"
+me="$(dirname \"$0\")"
 TIME=
 
 outfile=""
@@ -11,7 +10,7 @@ while :; do
     case "$1" in
       -tm|-time)
         shift
-        TIME="$(which time)";;
+        TIME=time
       -x|-include)
         shift
         shift;;
@@ -49,25 +48,26 @@ done
 #echo "the flags are $cxx_flags"
 #echo "the out file is $outfile"
 
-if [ -z $filename ]; then
+if [ -z "$filename" ]; then
     echo "usage: r++ [-dump | -bind] file.cpp"
     exit 255
 fi
 
-tmp=$(mktemp)
+tmp="$(mktemp)"
 
 #echo "the out file is $outfile"
 #echo "the temp file is $tmp"
 
-$TIME $CPP -xc++ -I$me/include -I$($CPP -print-file-name=include) \
+$TIME cpp -xc++ -I$me/include -I$(cpp -print-file-name=include) \
     -U__GNUC__ $cxx_flags "$filename" > "$tmp"
 # echo -n "preprocessed. "
 
 $TIME $me/r++0 $rxx_flags "$tmp"
 rtn=$?
 
-echo "parsed $(wc -l $tmp | awk '{print $1;}' ) loc"
-rm "$tmp"
+loc=$(wc -l <"$tmp")
+echo "parsed $loc loc"
+rm -- "$tmp"
 
 exit $rtn
 
