Beginnings of a patch: /etc/hosts

Igor Pechtchanski pechtcha@cs.nyu.edu
Wed Sep 11 16:15:00 GMT 2002


On Wed, 11 Sep 2002, Paul Johnston wrote:

> > No, I'm not.  I'm incorporating Warren Young's suggestion.  Unless someone
> > with ME can confirm that 'uname -s' returns CYGWIN_9*?  Nicholas?
>
> To me that's a step backwards - uname -s or $OS are the correct ways to
> detect the operating system. Warren's approach would be fooled if a user
> defined $SYSTEMROOT on Win 9x.

Win 9x does not set $OS...  At least my Win 98 machine at home doesn't.
Besides, the user can always set $OS to fool the script, by the same
token.  I'd prefer 'uname -s'.  Pending confirmation from someone with
Win ME...

> Nit picks... FILES=... should probably go nearer the top

Agreed.

> On reflection, I think we'll always want it verbose, so we could lose
> $VERBOSE

Probably.  In which case we should also print messages if the OS is not
detected or $WINETC is not found...

> That's gotta be it... in principle this is a very simple script!

Ok, one more iteration (script attached)...
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

It took the computational power of three Commodore 64s to fly to the moon.
It takes a 486 to run Windows 95.  Something is wrong here. -- SC sig file
-------------- next part --------------
#!/bin/sh
#--
# Creates symbolic links from some /etc files to their windows equivalents
#
# Version: 0.5
#
# ChangeLog:
#    v0.5 Igor Pechtchanski <pechtcha at cs.nyu.edu>:
#       Move FILES to top; removed VERBOSE (thx Paul Johnston)
#       Print messages on abnormal exit
#    v0.4 Igor Pechtchanski <pechtcha at cs.nyu.edu>:
#       Use $SYSTEMROOT and $WINDIR to determine the OS (thx Warren Young)
#       Check for existence of $WINETC directory (thx Paul Johnston)
#       Use `expr substr` instead of `echo | sed` (thx Joe Buehler)
#    v0.3 Igor Pechtchanski <pechtcha at cs.nyu.edu>:
#       Quote variable references (thx Joe Buehler)
#       Use `cygpath -W` instead of "$SYSTEMROOT" (thx Corinna Vinschen)
#       Change protocol to protocols on cygwin
#       Add ChangeLog
#    v0.2 Igor Pechtchanski <pechtcha at cs.nyu.edu>:
#       Use `uname -s` instead of "$OS"
#       Add Win9x support
#       Add networks file
#    v0.1 Paul Johnston <paj at pajhome.org.uk>:
#       Initial version
#--

FILES="hosts protocols services networks"

WINHOME=`/bin/cygpath -W`

if [ -n "$SYSTEMROOT" ]
then
  WINETC="$WINHOME/system32/drivers/etc"
elif [ -n "$WINDIR" ]
then
  WINETC="$WINHOME"
else
  echo "Unknown system type; exiting" >&2
  exit 0
fi

if [ ! -d "$WINETC" ]
then
  echo "Directory $WINETC does not exist; exiting" >&2
  exit 0
fi

for FILE in $FILES
do
  if [ ! -e "/etc/$FILE" ]
  then
    # Windows only uses the first 8 characters
    WFILE=`expr substr "$FILE" 1 8`
    /bin/ln -s -v "$WINETC/$WFILE" "/etc/$FILE"
  fi
done

-------------- next part --------------
--- make-etc-links.sh-orig	2002-09-11 18:08:39.000000000 -0400
+++ make-etc-links.sh	2002-09-11 18:57:01.000000000 -0400
@@ -2,9 +2,12 @@
 #--
 # Creates symbolic links from some /etc files to their windows equivalents
 #
-# Version: 0.4
+# Version: 0.5
 #
 # ChangeLog:
+#    v0.5 Igor Pechtchanski <pechtcha at cs.nyu.edu>:
+#       Move FILES to top; removed VERBOSE (thx Paul Johnston)
+#       Print messages on abnormal exit
 #    v0.4 Igor Pechtchanski <pechtcha at cs.nyu.edu>:
 #       Use $SYSTEMROOT and $WINDIR to determine the OS (thx Warren Young)
 #       Check for existence of $WINETC directory (thx Paul Johnston)
@@ -22,7 +25,7 @@
 #       Initial version
 #--
 
-VERBOSE=-v
+FILES="hosts protocols services networks"
 
 WINHOME=`/bin/cygpath -W`
 
@@ -33,12 +36,13 @@ elif [ -n "$WINDIR" ]
 then
   WINETC="$WINHOME"
 else
+  echo "Unknown system type; exiting" >&2
   exit 0
 fi
-FILES="hosts protocols services networks"
 
 if [ ! -d "$WINETC" ]
 then
+  echo "Directory $WINETC does not exist; exiting" >&2
   exit 0
 fi
 
@@ -48,7 +52,7 @@ do
   then
     # Windows only uses the first 8 characters
     WFILE=`expr substr "$FILE" 1 8`
-    /bin/ln -s $VERBOSE "$WINETC/$WFILE" "/etc/$FILE"
+    /bin/ln -s -v "$WINETC/$WFILE" "/etc/$FILE"
   fi
 done
 
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list