e2fsprogs/lib/ss/mk_cmds.sh.in

50 lines
912 B
Bash
Raw Normal View History

1997-04-26 17:21:57 +04:00
#!/bin/sh
#
#
DIR="${DIR-@datadir@/ss}"
SS_DIR="@SS_DIR@"
1997-04-26 17:21:57 +04:00
AWK=@AWK@
SED=@SED@
if test "x$1" = x ; then
echo "Usage: mk_cmds file"
exit 1
fi
if test -n "$_SS_DIR_OVERRIDE" ; then
DIR="$_SS_DIR_OVERRIDE";
fi
if test ! -f $DIR/ct_c.sed || test ! -f $DIR/ct_c.awk ; then
DIR="$SS_DIR"
# echo "Falling back to $DIR..."
if test ! -f "$DIR/ct_c.sed" || test ! -f "$DIR/ct_c.awk" ; then
echo "mk_cmds: Couldn't find mk_cmds's template files."
exit 1
fi
fi
FILE="$1"
1997-04-26 17:21:57 +04:00
ROOT=`echo $1 | sed -e s/.ct$//`
BASE=`basename "$ROOT"`
TMP="ct$$.c"
1997-04-26 17:21:57 +04:00
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}" -
1997-04-26 17:21:57 +04:00
if grep "^#__ERROR_IN_FILE" "${TMP}" > /dev/null; then
rm "${TMP}"
1997-04-26 17:21:57 +04:00
exit 1
else
rm -f "${BASE}.c"
mv -f "${TMP}" "${BASE}.c"
chmod -w "${BASE}.c"
1997-04-26 17:21:57 +04:00
exit 0
fi