--- install.orig 2002-05-28 10:02:06.000000000 -0400 +++ install 2002-05-30 13:45:17.000000000 -0400 @@ -11,13 +11,27 @@ This 'install' will adapt to the version of Windows that you are using and locate your cygwin root directory. It will modify the registry entries for -Drives and Directories under HKEY_CLASSES_ROOT, add a cygwin_indir.bat file in +Drives and Directories under HKEY_CLASSES_ROOT. + +The following are valid options: + bash - start bash from the default command shell + rxvt - start bash under rxvt + batch - run a batch file based on the current /cygwin.bat (default) + +Under batch, I will add a cygwin_indir.bat file in your cygwin root directory and append a few lines to your .bashrc. The changes to your .bashrc will only be executed if you are running under -cygwin (I share my .bashrc with my Unix box.) +cygwin (I share my .bashrc with my Unix box.) Also these changes will not +be run under other user profiles. + +The advantage of using the options bash or rxvt is that no temporary files are +used, and the extra command invocation in memory is spared. The rxvt command +used is a bare bones 'rxvt -e bash', so your preferences should go into +~/.Xdefaults EOF +# Add an odd apostrophe to stop the 'comment' leaking when viewing in xemacs' #################### Are you sure you want to do this? #################### PROMPT="Would you like to continue? [y/n]" @@ -35,14 +49,36 @@ fi echo "" -CYGWIN_ROOT_DOS=`regtool get 'HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/\native'` -CYGWIN_ROOT_CYGWIN=`cygpath -u $CYGWIN_ROOT_DOS` -CYGWIN_ROOT_DOS=`cygpath -w $CYGWIN_ROOT_DOS` +CYGWIN_ROOT_CYGWIN=/ +CYGWIN_ROOT_DOS=`cygpath -w $CYGWIN_ROOT_CYGWIN` -#################### Make necessary additions to .bashrc #################### +case $1 in +batch) + DESIRED_SHELL=%BATCH_SHELL_CMD% +;; +cmd-bash | bash) + DESIRED_SHELL=%CMD_BASH_SHELL_CMD% +;; +rxvt-bash | rxvt) + DESIRED_SHELL=%RXVT_BASH_SHELL_CMD% +;; +# Add you preferred windowing/shell combo here +# and then add appropriate start up line to .inf.tpl +*) + DESIRED_SHELL=%BATCH_SHELL_CMD% +;; +esac + +# Only modify/create ./bashrc and cygwin_indir.bat if running from a batch file +# otherwise things are handled in the registry and this isn't required +if [ "$DESIRED_SHELL" = "%BATCH_SHELL_CMD%" ] +then -if [ `grep -c BPH_TEMP_FILE $HOME/.bashrc` = 0 ]; then - cat <> $HOME/.bashrc +#################### Make necessary additions to .bashrc #################### +# create it if necesary + touch $HOME/.bashrc + if [ `grep -c /tmp/bphdir.tmp $HOME/.bashrc` = 0 ]; then + cat <> $HOME/.bashrc # Additions for "Cygwin Prompt Here" functionality if [ -r /tmp/bphdir.tmp ]; then @@ -52,38 +88,36 @@ # End of: Additions for "Cygwin Prompt Here" functionality EOF -fi - -#################### Create and install the .inf file #################### -# sed/shell quoting -- Ugh! -CYGWIN_ROOT_DOS_ESCAPED=`echo "$CYGWIN_ROOT_DOS" | sed -e 's;\\\\;\\\\\\\\;g'` -sed -e "s;\(CYGWIN_ROOT=\);\\1\"$CYGWIN_ROOT_DOS_ESCAPED\";g" \ - < CygwinPromptHere.inf.tpl > CygwinPromptHere.inf - -CYG_COMSPEC=`cygpath -u $COMSPEC` -INSTALL_CMD=`regtool get 'HKEY_CLASSES_ROOT\inffile\shell\Install\command\' \ - | sed -e 's; %1;;g'` -DOS_PWD=`cygpath -w -a "$PWD"` - -# Windows (2000) looks for the exact filename specified in the .inf file. -$CYG_COMSPEC /c start $INSTALL_CMD $DOS_PWD\\CygwinPromptHere.inf + fi #################### Create cygwin_indir.bat #################### # old CYGWIN_DRIVE=`echo $CYGWIN_ROOT_DOS | cut -d'\\' -f1` -CYGWIN_DRIVE=`echo $CYGWIN_ROOT_DOS | cut -d: -f1`: -CYGWIN_DIR=`echo $CYGWIN_ROOT_DOS | cut -d: -f2` + CYGWIN_DRIVE=`echo $CYGWIN_ROOT_DOS | cut -d: -f1`: + CYGWIN_DIR=`echo $CYGWIN_ROOT_DOS | cut -d: -f2` # Backup old file -if [ -r /cygwin_indir.bat ] -then + if [ -r /cygwin_indir.bat ] + then TODAY=`date +'%Y%m%d'` cp /cygwin_indir.bat /cygwin_indir.${TODAY}.bat echo "A copy of the existing file '/cygwin_indir.bat' has been saved as:" echo "/cygwin_indir.${TODAY}.bat." -fi + fi -cat < /cygwin_indir.bat +# if the standard cygwin.bat exists, pass it through sed to get cygwin_indir.bat +# so we retain the users options/preferences. Try and cygpath after cding to /bin +# else create it + if [ -x /cygwin.bat ] + then + cat < batch.sed +/\(\(cd\|chdir\).*bin\)[[:space:]]*$/I a\\ +cygpath -u %1> ..\\\\tmp\\\\bphdir.tmp +EOF + sed -f batch.sed /cygwin.bat > /cygwin_indir.bat + rm batch.sed + else + cat < /cygwin_indir.bat @echo off title Cygwin Bash Shell @@ -91,12 +125,28 @@ cd $CYGWIN_DIR\bin cygpath -u %1> $CYGWIN_ROOT_DOS\tmp\bphdir.tmp -rxvt -sr -sl 2500 -fg lightblue -geometry 90x30 -bg midnightblue -sb -tn rxvt -fn "Lucida Console-14" -e /usr/bin/bash --login -i +bash --login -i exit EOF + fi + chmod a+x /cygwin_indir.bat +fi + +#################### Create and install the .inf file #################### +# sed/shell quoting -- Ugh! +CYGWIN_ROOT_DOS_ESCAPED=`echo "$CYGWIN_ROOT_DOS" | sed -e 's;\\\\;\\\\\\\\;g'` +sed -e "s;\(CYGWIN_ROOT=\);\\1\"$CYGWIN_ROOT_DOS_ESCAPED\";g" -e "s;%CYGWIN_SHELL_CMD%;$DESIRED_SHELL;g" \ + < CygwinPromptHere.inf.tpl > CygwinPromptHere.inf + +CYG_COMSPEC=`cygpath -u $COMSPEC` +INSTALL_CMD=`regtool get 'HKEY_CLASSES_ROOT\inffile\shell\Install\command\' \ + | sed -e 's; %1;;g'` +DOS_PWD=`cygpath -w -a "$PWD"` + +# Windows (2000) looks for the exact filename specified in the .inf file. +$CYG_COMSPEC /c start $INSTALL_CMD $DOS_PWD\\CygwinPromptHere.inf -chmod a+x /cygwin_indir.bat #################### Installation Complete ####################