This is the mail archive of the cygwin 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]
Other format: [Raw text]

1.5.11 on XP: spaces in HOME and my resolution


I just downloaded and installed the latest (2 days old, at the time I write
this) version of Cygwin. I had several issues relating back to my Home
directory having spaces from my XP profile; mostly from external apps such
as KDE. I expect this is known, and I have looked it up in the archives and
in Google, but whether or not there is curently a resolution is not clear.
Below is my fix in the hopes that it is helpful (I couldn't find anything
similar as I searched.)

First, however, it appears that this is not supposed to be the standard
behavior. According to this post:
http://www.cygwin.com/ml/cygwin/2003-01/msg00111.html
it seems that this behavior is attributed to a HOME directory being set in
the environment. In my case, this is not so, as you can see from the
attached cygcheck output. 

If I install cygwin and run Bash on a clean machine, the path with spaces is
already set in etc/passwd as below, so I changed it to the short filename
version and that fixed most of the issues I was having.

NBRYANT:unused_by_nt/2000/xp:198884:10545:NBRYANT,U-WFBS\NBRYANT,S-1-5-21-[r
emoved]:/cygdrive/c/Documents and Settings/NBRYANT:/bin/bash

In the archives, I found mention that setting this in the cygwin.bat file is
a bad idea because of the possibility of mixing up docume~1 and docume~2,
etc. If this is the only issue with short file names, then I submit my
modified cygwin.bat file.
============================================================================
==
@echo off

IF NOT DEFINED HOME (
 for %%x IN (%USERPROFILE%) DO (set HOME=%%x)
 if NOT "%HOME%"=="%USERPROFILE%" (
  if "%OS%"=="Windows_NT" (
   for /D %%x IN ("%USERPROFILE%") DO (set HOME=%%~fsx)
  )
 )
)

C:
chdir C:\cygwin\bin

bash --login -i %1
============================================================================
==

This will set the HOME variable in the shell to the shortfilename version of
%USERPROFILE% and should work in any version of NT (I've only tried it in
XP, and it works just fine.) It cleared up my issues with KDE and other
software instantly.

I typed this up only in the hopes of contributing something to your
excellent project ... if it is counterproductive or actually has been
addressed, I apologize. On the other hand, if it would be helpful, you are
free to use it; I wrote it, it's mine, and I give it to you. If there is
interest, I should be able to expand it to '95/'98 (which you have to
shorten a different way).

Actually, while I'm at it, this should work for all versions (again, I've
only tested it on XP.
============================================================================
==
@echo off

C:
chdir C:\cygwin\bin

IF NOT DEFINED HOME (
 for %%x IN (%USERPROFILE%) DO (set HOME=%%x)
 if NOT "%HOME%"=="%USERPROFILE%" (
  if "%OS%"=="Windows_NT" (
   for /D %%x IN ("%USERPROFILE%") DO (set HOME=%%~fsx)
  ) ELSE (
   REM For Win9x, etc
   cygpath -d "%USERPROFILE%"| cat -b > sethome.bat
   echo set HOME=%%1>1.bat
   call sethome.bat
   del sethome.bat
   del 1.bat
  )
 )
)

bash --login -i %1
============================================================================
==

Incidentally, the %1 in the last line allows me to run shell scripts
directly from Win shortcuts, but does not affect normal execution: ie, since
the startx.bat files won't show the background when windowed, my shortcut is
thus:

C:\cygwin\cygwin.bat C:\cygwin\usr\X11R6\bin\kde.sh

But when the desktop Cygwin icon is launched, it functions as always.

~Neil

Attachment: cygcheck.txt
Description: Text document

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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