This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: set HOME environment


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 cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]