Subject: Couple more tiny patches for fvwmrc_convert

From: Julian Gilbey <[email-masked]>
Date: Wed, 10 Mar 1999 12:54:29 +0000 (GMT)

Couple more tiny bits and pieces for fvwmrc_convert: this sends all
error and info messages to stderr instead of stdout, and attempts to
preserve file permissions as much as is possible.  It also avoids
replacing "Restart fvwm2" by "Restart fvmw22"!  (The stderr instead of
stdout is so that if $dest="-" then the messages don't get
intermingled with the output.)

BTW, my previous patch (to fvwmrc_convert and the FindPopup bug) could
certainly be also applied to the 2.2 branch as a bugfix (I can mail it
again to someone if necessary); this one is much more cosmetic but
could also be seen as a bugfix and similarly applied to 2.2 as well as
the 2.3 track.

   Julian

--- fvwmrc_convert.orig	Wed Mar 10 12:27:40 1999
+++ fvwmrc_convert	Wed Mar 10 12:47:57 1999
@@ -30,24 +30,26 @@
 # of Austin Donnelly <[email-masked]>, 1 Mar 1999
 # Further major corrections by Julian Gilbey <[email-masked]>, 3 Mar 1999
 
-echo "fvwmrc-to-fvwm2rc"
+echo "fvwmrc-to-fvwm2rc" >&2
 
 # Point this to your gawk/nawk/awk exec:
 AWK=/usr/bin/awk
 
 if [ ! -x $AWK ];then
-   echo "$AWK missing, cannot run"
+   echo "$AWK missing, cannot run" >&2
    exit 1
 fi
 source=${1:-$HOME/.fvwmrc}
 dest=${2:-$HOME/.fvwm2rc}
 if [ "$dest" != "-" ] ;then
-	echo "Output to $dest"
+	echo "Output to $dest" >&2
 	if [ -f $dest ] ; then
-	  mv $dest $dest.bak
-	  echo "Saving existing $dest as $dest.bak"
+	  echo "Saving existing $dest as $dest.bak" >&2
+	  cp -p $dest $dest.bak || { echo "Couldn't save; aborting" >&2; exit 1; }
+	else
+	  cp -p $source $dest 2>/dev/null  # try to preserve permissions
 	fi
-	exec >$dest
+	exec >$dest || { echo "Couldn't write to $dest, aborting" >&2; exit 1; }
 	TTY=`tty`
 	if [ ! -w "$TTY" ] ;then
 	  TTY=/dev/stderr
@@ -61,7 +63,7 @@
 
 cat $source | $AWK '
 BEGIN   {
-        printf ("# Trying to compile an old .fvwrc to the  new fvwm-2.0 Format\n");
+        printf ("# Trying to compile an old .fvwrc to the new fvwm-2.xx Format\n");
 	TRUE=1; FALSE=0;
 
 	IGNORECASE=TRUE;
@@ -98,7 +100,9 @@
 }
 	
 ################ Rename common items ##############
-/Restart/ && /fvwm/             { gsub("fvwm", "fvwm2"); } # try and leave paths alone
+/Restart/ && /fvwm/             {
+	gsub("fvwm", "fvwm2"); gsub("fvwm22","fvwm2"); # try to leave paths alone
+}
 /GoodStuff/                     { gsub("GoodStuff", "FvwmButtons"); }
 
 ############ Chop off trailing "&" from Exec commands ##########

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  Julian Gilbey, Dept of Maths, QMW, Univ. of London. [email-masked]
             Debian GNU/Linux Developer.  [email-masked]
       -*- Finger [email-masked] for my PGP public key. -*-
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]