Subject: Re: set HOME environment
From: Randall R Schulz <[email-masked]>
To: David Starks-Browning <[email-masked]>, Guansong Zhang <[email-masked]>
Cc: [email-masked]
Date: Thu, 14 Sep 2000 08:41:03 -0700

Hi,

The presence of spaces in file name and path variables is indeed
problematic. In particular, the PATH variable inherited by the shell
from the Windows environment is rather likely to contain them, and
programs that try to manipulate these variables assuming that they
have no spaces will surely break.

Here's something I've done in lieu of fixing all the scripts I wrote
with the tacit assumption of a space-less PATH variable:

-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
if [ -z "$SYSPATH" ]; then
    export            SYSPATH="$PATH"
    export            SAFE_SYSPATH="$(echo "$PATH" |sed -e 's/^[^:]* [^:]*://g' \
                                                      -e 's/:[^:]* [^:]*//g' )"

    syspath()        { echo "$SYSPATH" |tr ':' $'\n'; }
    safesyspath()    { echo "$SAFE_SYSPATH" |tr ':' $'\n'; }
fi

resetPATH() {
    # /usr/local/bin is first to give precedence to CygUtils
    #    (see <http://cygutils.netpedia.net/>)

    FULL_PATH=":$HOME/bin:/usr/sbin://c/jdk1.3/bin:$SYSPATH"
    SAFE_PATH=":$HOME/bin:/usr/sbin://c/jdk1.3/bin:$SAFE_SYSPATH"
}

safePATH()            { PATH="$SAFE_PATH"; }
fullPATH()            { PATH="$FULL_PATH"; }

resetSafePATH()        { resetPATH; safePATH; }
resetFullPATH()        { resetPATH; fullPATH; }
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-

I keep this code in a file called ~/.PATH, source that file in my
.bash_profile and immediately thereafter invoke "resetSafePATH". If I
ever need access to the directories excised from SAFE_PATH, I can
issue "resetFullPATH" to get them back.

I hope some might find this useful.

Randall Schulz
Teknowledge Corp.
Palo Alto, CA USA

At 11:22 +0100 9/14/00, David Starks-Browning wrote:
>....
>
>That $USER may contain a space is another matter.  Adding quotes in
>/etc/profile will permit HOME to be defined correctly, space and all,
>but whenever $HOME is substituted, things are likely to break.  That's
>why nobody would (intentionally) have USER/LOGNAME/HOME with an
>embedded space in UNIX.  If you want Cygwin to work well, you have to
>deal with this.
>
>It's probably better in the long run if these windows users picked a
>new, space-less USER and/or HOME variable and set that explicitly in
>/etc/profile.
>
>...
>
>Cheers,
>David

--
Want to unsubscribe from this list?
Send a message to [email-masked]