[26508] in Source-Commits
Re: /svn/athena r25593 - trunk/debathena/debathena/dotfiles
daemon@ATHENA.MIT.EDU (Benjamin Kaduk)
Sun Jul 1 23:55:59 2012
Date: Sun, 1 Jul 2012 23:55:56 -0400 (EDT)
From: Benjamin Kaduk <kaduk@MIT.EDU>
To: Jonathan D Reed <jdreed@MIT.EDU>
cc: source-commits@MIT.EDU
In-Reply-To: <201206292225.q5TMP3qH031477@drugstore.mit.edu>
Message-ID: <alpine.GSO.1.10.1207012341020.18441@multics.mit.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
On Fri, 29 Jun 2012, Jonathan D Reed wrote:
> 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
These calls to test(1) want '-eq' (not '='), right?
> + 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."
We mention .bashrc.mine for the LD_ASSUME_KERNEL bit, but not here. Not
sure whether we care... (if we do, the csh version needs it, too).
> 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
Oof, we need /bin/grep here? Sorry I missed that.
> 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."
This is different than the text in the bash version. Probably the bash
version is better.
-Ben
> + 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
>
>