[26496] in Source-Commits

home help back first fref pref prev next nref lref last post

/svn/athena r25593 - trunk/debathena/debathena/dotfiles

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Fri Jun 29 18:25:04 2012

Date: Fri, 29 Jun 2012 18:25:03 -0400
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201206292225.q5TMP3qH031477@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: jdreed
Date: 2012-06-29 18:25:03 -0400 (Fri, 29 Jun 2012)
New Revision: 25593

Modified:
   trunk/debathena/debathena/dotfiles/bashrc
   trunk/debathena/debathena/dotfiles/cshrc
Log:
- Don't use Bourne variable syntax in csh
- Use the same idiom in both shells
- Use a variable for all messages to avoid duplication


Modified: trunk/debathena/debathena/dotfiles/bashrc
===================================================================
--- trunk/debathena/debathena/dotfiles/bashrc	2012-06-29 21:57:02 UTC (rev 25592)
+++ trunk/debathena/debathena/dotfiles/bashrc	2012-06-29 22:25:03 UTC (rev 25593)
@@ -147,31 +147,21 @@
     fi
 fi
 if [ "${skip_sanity_checks+set}" != set ]; then
-    IFS=:
-    bin=no
-    usrbin=no
-    for p in $PATH; do
-	case $p in
-	    /bin)
-		bin=yes
-		;;
-	    /usr/bin)
-		usrbin=yes
-		;;
-	esac
-    done
-    unset IFS
-    if [ "$bin" != "yes" ] || [ "$usrbin" != "yes" ]; then
-	text="You appear to have incorrectly modified your PATH variable in your dotfiles,\nand as such have deleted /bin and/or /usr/bin from your PATH, which\nwill likely cause this login session to fail.  Please correct this problem."
+    missing=0
+    echo $path | /usr/bin/tr ':' '\n' | /bin/grep -Fqx /bin
+    [ $? = 0 ] || missing=1
+    echo $path | /usr/bin/tr ':' '\n' | /bin/grep -Fqx /usr/bin
+    [ $? = 0 ] || missing=1
+    if [ $missing -eq 1 ]; then
+	text="You appear to have incorrectly modified your PATH variable in your dotfiles,\nand as such have deleted /bin and/or /usr/bin from your PATH, which\nwill likely cause this login session to fail.  Please correct this problem.\nYou can set the skip_sanity_checks variable to disable this message."
 	echo -e "$text" >&2
 	[ -n "$DISPLAY" ] && /usr/bin/zenity --warning --text="$text"
     fi
     if [ -n "$LD_ASSUME_KERNEL" ]; then
 	unset LD_ASSUME_KERNEL
-	echo "In your shell customizations, you set LD_ASSUME_KERNEL.  This is a bad idea." >&2
-	echo "We have unset it for you." >&2
-	echo "If you really did want that, set skip_sanity_checks=y in your .bashrc.mine." >&2
-	[ -n "$DISPLAY" ] && /usr/bin/zenity --warning --text="You tried to set LD_ASSUME_KERNEL in your shell customizations.  Don't do that.\nWe have unset it for you.\nSet skip_sanity_checks=y in your ~/.bashrc.mine if you really want that."
+	text="In your shell customizations, you set LD_ASSUME_KERNEL.  This is a bad idea.\nIt has been unset.\nIf you really did want that, set the skip_sanity_checks variable in your .bashrc.mine."
+	echo -e "$text" >&2
+	[ -n "$DISPLAY" ] && /usr/bin/zenity --warning --text="$text"
     fi
 fi
 

Modified: trunk/debathena/debathena/dotfiles/cshrc
===================================================================
--- trunk/debathena/debathena/dotfiles/cshrc	2012-06-29 21:57:02 UTC (rev 25592)
+++ trunk/debathena/debathena/dotfiles/cshrc	2012-06-29 22:25:03 UTC (rev 25593)
@@ -184,17 +184,17 @@
 endif
 
 if (! $?skip_sanity_checks) then
-  echo $path | /usr/bin/tr ':' '\n' | grep -Fqx /bin
-  missing=0
+  set missing=0
+  echo $path | /usr/bin/tr ':' '\n' | /bin/grep -Fqx /bin
   if ( $? != 0 ) then
-    missing=1
+    set missing=1
   endif
-  echo $path | /usr/bin/tr ':' '\n' | grep -Fqx /usr/bin
+  echo $path | /usr/bin/tr ':' '\n' | /bin/grep -Fqx /usr/bin
   if ( $? != 0 ) then
-    missing=1
+    set missing=1
   endif
   if ( $missing == 1 ) then
-    text="You appear to have incorrectly modified your PATH variable in your dotiles,\nand as such have deleted /bin and/or /usr/bin from your PATH, which\nwill likely cause this login session to fail.  Please correct this problem."
+    set text="You appear to have incorrectly modified your PATH variable in your dotiles,\nand as such have deleted /bin and/or /usr/bin from your PATH, which\nwill likely cause this login session to fail.  Please correct this problem.\nThis warning can be disabled by setting the skip_sanity_checks variable."
     echo "$text" > /dev/stderr
     if ( $?DISPLAY) then
       /usr/bin/zenity --warning --text="$text"
@@ -202,10 +202,10 @@
   endif
   if ( $?LD_ASSUME_KERNEL ) then
     unsetenv LD_ASSUME_KERNEL
-    echo "Setting LD_ASSUME_KERNEL in your dotfiles is a bad idea." > /dev/stderr
-    echo "We have unset it for you.  Set skip_sanity_checks=y if you really wanted it." > /dev/stderr
+    set text="Setting LD_ASSUME_KERNEL in your dotfiles is a bad idea.\nIt has been unset for you.\nSet the skip_sanity_checks variable if you really wanted it."
+    echo "$text" > /dev/stderr
     if ( $?DISPLAY) then
-      /usr/bin/zenity --warning --text="You set LD_ASSUME_KERNEL in your dotfiles which is a bad idea.\nWe have unset it for you.\nSet skip_sanity_checks=y if you really wanted it."
+      /usr/bin/zenity --warning --text="$text"
     endif
   endif     
 endif


home help back first fref pref prev next nref lref last post