Whamcloud - gitweb
Make compile_et and mk_cmds safe from directory pathnames that
authorTheodore Ts'o <tytso@mit.edu>
Mon, 17 Sep 2001 03:29:17 +0000 (23:29 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 17 Sep 2001 03:29:17 +0000 (23:29 -0400)
contain spaces.

lib/et/ChangeLog
lib/et/compile_et.sh.in
lib/ss/ChangeLog
lib/ss/mk_cmds.sh.in

index c1104a3..b70be6c 100644 (file)
@@ -1,3 +1,8 @@
+2001-09-16  Theodore Tso  <tytso@valinux.com>
+
+       * compile_et.sh.in: Make the shell script safe from directory
+               pathnames with spaces.
+
 2001-09-10  Theodore Tso  <tytso@valinux.com>
 
        * com_err.texinfo: Add appropriate @node and @menu lines so that
index ccc2434..ad445fa 100644 (file)
@@ -3,17 +3,17 @@
 #
 AWK=@AWK@
 DIR="${DIR-@datadir@/et}"
-ET_DIR=@ET_DIR@
+ET_DIR="@ET_DIR@"
 
 if test "x$1" = x ; then
     echo "Usage: compile_et file"
     exit 1
 fi
 
-if test ! -f $DIR/et_h.awk -o ! -f $DIR/et_c.awk ; then
-    DIR=$ET_DIR
+if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then
+    DIR="$ET_DIR"
 #    echo "Falling back to $DIR..."
-    if test ! -f $DIR/et_h.awk -o ! -f $DIR/et_c.awk ; then
+    if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then
        echo "compile_et: Couldn't find compile_et's template files."
        exit 1
     fi
@@ -22,10 +22,10 @@ fi
 ROOT=`echo $1 | sed -e s/.et$//`
 BASE=`basename $ROOT`
 
-if test ! -f $ROOT.et ; then
+if test ! -f "$ROOT.et" ; then
     echo "compile_et: $ROOT.et: File not found"
     exit 1;
 fi
 
-$AWK -f ${DIR}/et_h.awk outfile=${BASE}.h $ROOT.et
-$AWK -f ${DIR}/et_c.awk outfile=${BASE}.c $ROOT.et
+$AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h" "$ROOT.et"
+$AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c" "$ROOT.et"
index c768b7b..3c1c290 100644 (file)
@@ -1,3 +1,8 @@
+2001-09-16  Theodore Tso  <tytso@valinux.com>
+
+       * mk_cmds.sh.in: Make the shell script safe from directory
+               pathnames with spaces.
+
 2001-09-02  Theodore Tso  <tytso@thunk.org>
 
        * Release of E2fsprogs 1.24a
index cc74274..c35d6b0 100644 (file)
@@ -3,7 +3,7 @@
 #
 
 DIR="${DIR-@datadir@/ss}"
-SS_DIR=@SS_DIR@
+SS_DIR="@SS_DIR@"
 AWK=@AWK@
 SED=@SED@
 
@@ -13,36 +13,36 @@ if test "x$1" = x ; then
 fi
 
 if test -n "$_SS_DIR_OVERRIDE" ; then
-    DIR=$_SS_DIR_OVERRIDE;
+    DIR="$_SS_DIR_OVERRIDE";
 fi
 
 if test ! -f $DIR/ct_c.sed -o ! -f $DIR/ct_c.awk ; then
-    DIR=$SS_DIR
+    DIR="$SS_DIR"
 #    echo "Falling back to $DIR..."
-    if test ! -f $DIR/ct_c.sed -o ! -f $DIR/ct_c.awk ; then
+    if test ! -f "$DIR/ct_c.sed" -o ! -f "$DIR/ct_c.awk" ; then
        echo "mk_cmds: Couldn't find mk_cmds's template files."
        exit 1
     fi
 fi
 
-FILE=$1
+FILE="$1"
 ROOT=`echo $1 | sed -e s/.ct$//`
-BASE=`basename $ROOT`
-TMP=ct$$.c
+BASE=`basename "$ROOT"`
+TMP="ct$$.c"
 
-if test ! -f $FILE ; then
+if test ! -f "$FILE" ; then
     echo "$FILE: File not found"
     exit 1;
 fi
 
-${SED} -f ${DIR}/ct_c.sed  ${FILE} \
-       | ${AWK} -f ${DIR}/ct_c.awk rootname=${ROOT} outfile=${TMP} -
+${SED} -f "${DIR}/ct_c.sed"  "${FILE}" \
+       | ${AWK} -f "${DIR}/ct_c.awk" "rootname=${ROOT}" "outfile=${TMP}" -
 
-if grep "^#__ERROR_IN_FILE" ${TMP} > /dev/null; then
-       rm ${TMP}
+if grep "^#__ERROR_IN_FILE" "${TMP}" > /dev/null; then
+       rm "${TMP}"
        exit 1
 else
-       rm -f ${BASE}.c
-       mv ${TMP} ${BASE}.c
+       rm -f "${BASE}.c"
+       mv "${TMP}" "${BASE}.c"
        exit 0
 fi