[mlpack-svn] r13388 - mlpack/trunk/CMake
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Aug 10 20:05:46 EDT 2012
Author: rcurtin
Date: 2012-08-10 20:05:45 -0400 (Fri, 10 Aug 2012)
New Revision: 13388
Modified:
mlpack/trunk/CMake/allexec2man.sh
mlpack/trunk/CMake/exec2man.sh
Log:
Safer handling of strings which may have spaces in them.
Modified: mlpack/trunk/CMake/allexec2man.sh
===================================================================
--- mlpack/trunk/CMake/allexec2man.sh 2012-08-11 00:05:27 UTC (rev 13387)
+++ mlpack/trunk/CMake/allexec2man.sh 2012-08-11 00:05:45 UTC (rev 13388)
@@ -8,15 +8,15 @@
#
# For the executable 'cheese', the file 'cheese.1.gz' will be created in the
# output directory.
-exec2man=$1
-outdir=$2
+exec2man="$1"
+outdir="$2"
-mkdir -p $outdir
+mkdir -p "$outdir"
for program in `find . -perm /u=x,g=x,o=x | \
grep -v '[.]$' | \
grep -v '_test$' | \
sed 's|^./||'`; do
echo "Generating man page for $program...";
- $1 $program $outdir/$program.1
- gzip -f $outdir/$program.1
+ $1 "$program" "$outdir/$program.1"
+ gzip -f "$outdir/$program.1"
done
Modified: mlpack/trunk/CMake/exec2man.sh
===================================================================
--- mlpack/trunk/CMake/exec2man.sh 2012-08-11 00:05:27 UTC (rev 13387)
+++ mlpack/trunk/CMake/exec2man.sh 2012-08-11 00:05:45 UTC (rev 13388)
@@ -11,12 +11,12 @@
# No warranties...
#
# @author Ryan Curtin
-name=$1
-output=$2
+name="$1"
+output="$2"
# Generate the synopsis.
# First, required options.
-reqoptions=`./$name -h | \
+reqoptions=`./"$name" -h | \
awk '/Required options:/,/Options:/' | \
grep '^ --' | \
sed 's/^ --/--/' | \
@@ -30,7 +30,7 @@
sed 's/\]//g'`
# Then, regular options.
-options=`./$name -h | \
+options=`./"$name" -h | \
awk '/Options:/,/For further information,/' | \
grep '^ --' | \
sed 's/^ --/--/' | \
@@ -65,16 +65,16 @@
# helps avoid 'man' warnings).
# The sed line at the end removes accidental macros from the output, replacing
# 'word' with "word".
-./$name -h | \
+./"$name" -h | \
sed 's/^For further information/Additional Information\n\n For further information/' | \
sed 's/^consult the documentation/ consult the documentation/' | \
sed 's/^distribution of MLPACK./ distribution of MLPACK./' | \
awk -v syn="$synopsis" \
- '{ if (NR == 1) print "NAME\n '$name' - "tolower($0)"\nSYNOPSIS\n "syn" \nDESCRIPTION\n" ; else print } ' | \
+ '{ if (NR == 1) print "NAME\n '"$name"' - "tolower($0)"\nSYNOPSIS\n "syn" \nDESCRIPTION\n" ; else print } ' | \
sed '/^[^ ]/ y/qwertyuiopasdfghjklzxcvbnm:/QWERTYUIOPASDFGHJKLZXCVBNM /' | \
sed 's/ / /g' | \
awk '/NAME/,/REQUIRED OPTIONS/ { print; } /ADDITIONAL INFORMATION/,0 { print; } /REQUIRED OPTIONS/,/ADDITIONAL INFORMATION/ { if (!/REQUIRED_OPTIONS/ && !/OPTIONS/ && !/ADDITIONAL INFORMATION/) { if (/ --/) { printf "\n" } sub(/^[ ]*/, ""); sub(/ [ ]*/, " "); printf "%s ", $0; } else { if (!/REQUIRED OPTIONS/ && !/ADDITIONAL INFORMATION/) { print "\n"$0; } } }' | \
sed 's/ ADDITIONAL INFORMATION/\n\nADDITIONAL INFORMATION/' | \
- txt2man -P mlpack -t $name -d 1 | \
- sed "s/^'\([A-Za-z0-9 ]*\)'/\"\1\"/" > $output
+ txt2man -P mlpack -t "$name" -d 1 | \
+ sed "s/^'\([A-Za-z0-9 ]*\)'/\"\1\"/" > "$output"
More information about the mlpack-svn
mailing list