Hello,
I've wrote me a script that checks for new configuration files after a Slackware upgrade. In Slackware, updates in /etc come as files ending in ".new", i.e. inittab.new. This is of course to avoid screwing up a working configuration. Now, I've written a script that uses
find to locate the .new files. It then checks if the corresponding "old" file exists, and asks me if I want to
diff them. Then it asks if I want to move the .new file over the old file. Like this:
Code:
#!/bin/sh
DIR=/etc
[ x`echo $1` != x ] && DIR=$1
echo "Checking for .new files in $DIR..."
find $DIR -xdev -name '*.new' | while read NEWFILE ; do
OLDFILE=${NEWFILE%%.new}
if [ -e "$NEWFILE" -a -e "$OLDFILE" ] ; then
AGE=older
[ `find "$NEWFILE" -cnewer "$OLDFILE" | grep -c .new` -gt 0 ] && AGE=newer
echo -n "$NEWFILE is $AGE than $OLDFILE. Wanna diff them? (y/N)"
read ANSWER
[ x`echo $ANSWER` == xy ] && diff -bB "$NEWFILE" "$OLDFILE"
else
echo "$NEWFILE has no $OLDFILE counterpart."
fi
echo -n "Wanna move $NEWFILE to $OLDFILE? (y/N)"
read ANSWER
[ x`echo $ANSWER` == xy ] && mv -iv "$NEWFILE" "$OLDFILE"
done
Now my problem: the script doesn't stop and prompt me for an answer at the read statements. It just skips them, and I have absolutely no idea why. I've been staring me blind at this darn script and all I've managed is to start thinking that the problem doesn't really have to do with the read statements. But I can't see what's wrong. Does anyone have a clue?
TIA,
Bebo