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

Re: [ITP] chere


On Mon, Oct 11, 2004 at 07:30:51AM -0700, Dave wrote:
>As mentioned last week, here's the proper (I hope) ITP.
>
># chere
>sdesc: "Cygwin Prompt Here context menus"
>ldesc: "Shell script to manage shell here context menus for Cygwin"
>category: shells utils system
>requires: ash cygwin sh-utils cygutils
>
>Links to where you can download. Just strip the zip and txt extensions that
>geocities are enforcing.
>
>http://www.geocities.com/d_inabox/chere-0.2-1.tar.bz2.zip
>http://www.geocities.com/d_inabox/setup.hint.txt
>
>It's my first package, so let me know if I'm doing things wrong.

I tried this out but I get nothing but, e.g.,

      c:\tmp
      Access is denied.

whenever I right-click on a directory and choose, e.g., "Zsh here".

I've tried both with and without rxvt.

The problem is apparently due to the fact that you're using "forward"
slashes in the path components and XP doesn't like that.  The patch
below fixes that problem.  It uses "cygpath" to figure out the locations
of the term and shell programs, which is a more robust method for
getting the right path.  I also added some double quotes to one place to
defend against directories with spaces in them.

On looking at the patch, it seems like if you adopt what I did to
SHELL_CMD and SHELL_EXE, you might want to do something similar for
TERM_CMD and TERM_EXE just for consistency.

I haven't tested this exhaustively but this gets things working for me.

Btw, I love the implementation and the extensive help.  Would you consider
adding a man page with this info at some point?

Oh, btw, a +20 from me.

cgf

--- bin/chere	2004-10-10 17:40:02.000000000 -0400
+++ /smb/f/cygwin/bin/chere	2004-10-11 11:24:12.000000000 -0400
@@ -194,10 +194,10 @@ if [ $ACTION = i ]; then
 	 TERM_EXE=command.com;;
 	esac;;
   rxvt )
-	TERM_CMD="$CYG_DIR/bin/rxvt.exe -e"
+	TERM_CMD="/bin/rxvt.exe -e"
 	TERM_EXE="/bin/rxvt.exe";;
   xterm )
-	TERM_CMD="$CYG_DIR/bin/xterm.exe -e"
+	TERM_CMD="/bin/xterm.exe -e"
 	TERM_EXE="/bin/xterm.exe";;
   * )
 	echo $0 Error: Unknown terminal $this_term
@@ -217,30 +217,30 @@ if [ $ACTION = i ]; then
  # the description text to be displayed in control panel uninstall window
  case $this_shell in
   bash )
-	SHELL_CMD="$CYG_DIR/bin/bash -l -c \\\"cd '%L'; exec /bin/bash\\\""
+	SHELL_CMD="-l -c \\\"cd '%L'; exec /bin/bash\\\""
 	SHELL_EXE="/bin/bash.exe"
 	ACCEL="&Bash Here"
 	CPH_DESC="Cygwin Bash Prompt Here";;
   ash )
 	# TODO How to make this a login shell? Is -l undocumented?
-	SHELL_CMD="$CYG_DIR/bin/sh -c \\\"cd '%L'; exec /bin/sh\\\"";
+	SHELL_CMD="-c \\\"cd '%L'; exec /bin/sh\\\"";
 	SHELL_EXE="/bin/sh.exe"
 	ACCEL="&Ash Here"
 	CPH_DESC="Cygwin Ash Prompt Here";;
   pdksh )
-	SHELL_CMD="$CYG_DIR/bin/pdksh -l -c \\\"cd '%L'; exec /bin/pdksh\\\""
+	SHELL_CMD="-l -c \\\"cd '%L'; exec /bin/pdksh\\\""
 	SHELL_EXE="/bin/pdksh.exe"
 	ACCEL="&Pdksh Here"
 	CPH_DESC="Cygwin Pdksh Prompt Here";;
   tcsh )
 	# Apparently -l only applies if it is the only argument
 	# so this may not work
-	SHELL_CMD="$CYG_DIR/bin/tcsh -l -c \\\"cd '%L'; exec /bin/tcsh\\\""
+	SHELL_CMD="-l -c \\\"cd '%L'; exec /bin/tcsh\\\""
 	SHELL_EXE="/bin/tcsh.exe"
 	ACCEL="&Tcsh Here"
 	CPH_DESC="Cygwin Tcsh Prompt Here";;
   zsh )
-	SHELL_CMD="$CYG_DIR/bin/zsh -l -c \\\"cd '%L'; exec /bin/zsh\\\""
+	SHELL_CMD="-l -c \\\"cd '%L'; exec /bin/zsh\\\""
 	SHELL_EXE="/bin/zsh.exe"
 	ACCEL="&Zsh Here"
 	CPH_DESC="Cygwin Zsh Prompt Here";;
@@ -267,8 +267,8 @@ if [ $ACTION = i ]; then
 	# When evaluated into a variable, need another level of quoting:
 	# "c:\cygwin\bin\sh -c \\\"scmd=\\\`sed -n \\\\\\\"s?\\\\\\\`id -un\\\\\\\`:.*:\\\\\\\\\\\\(.*\\\\\\\\\\\\)?\\\\\\\\\\\\1?gp\\\\\\\" /etc/passwd\\\`; \\\$scmd -l -c \\\\\\\"cd '%1'; exec \\\$scmd\\\\\\\"\\\""
 	# Ouch. If you think it can be quoted better, let me know.
-	SHELL_CMD="$CYG_DIR/bin/sh -c \\\"scmd=\\\`sed -n \\\\\\\"s?\\\\\\\`id -un\\\\\\\`:.*:\\\\\\\\\\\\(.*\\\\\\\\\\\\)?\\\\\\\\\\\\1?gp\\\\\\\" /etc/passwd\\\`; \\\$scmd -l -c \\\\\\\"cd '%L'; exec \\\$scmd\\\\\\\"\\\""
-	SHELL_EXE=/bin/sh
+	SHELL_CMD="-c \\\"scmd=\\\`sed -n \\\\\\\"s?\\\\\\\`id -un\\\\\\\`:.*:\\\\\\\\\\\\(.*\\\\\\\\\\\\)?\\\\\\\\\\\\1?gp\\\\\\\" /etc/passwd\\\`; \\\$scmd -l -c \\\\\\\"cd '%L'; exec \\\$scmd\\\\\\\"\\\""
+	SHELL_EXE="/bin/sh.exe"
 	ACCEL="Shell Prompt &Here"
 	CPH_DESC="Cygwin Prompt Here"
 
@@ -310,7 +310,7 @@ if [ $ACTION = i ]; then
    exit
   fi
  fi
- if [ ! -x "$SHELL_EXE" ] && [ $this_shell != cmd ]; then
+ if [ ! -x "$SHELL_EXE" ] && [ "$this_shell" != cmd ]; then
   if [ $FORCE = t ]; then
    echo $0 Warning: $SHELL_EXE not found
   else
@@ -322,6 +322,8 @@ if [ $ACTION = i ]; then
   fi
  fi
 
+ [ -n "$TERM_CMD" ] && TERM_CMD=$(cygpath -w "$TERM_CMD")
+ SHELL_EXE=$(cygpath -w "$SHELL_EXE")
  ####### Install ###########
  if [ $FORCE = t ] || ! $REGTOOL_ check $DRIVE_KEY/cygwin_$this_shell 2> /dev/null ; then
   # Add Registry Key for Drives
@@ -329,10 +331,10 @@ if [ $ACTION = i ]; then
   $REGTOOL -s set $DRIVE_KEY/cygwin_$this_shell/ \"$ACCEL\"
   $REGTOOL add $DRIVE_KEY/cygwin_$this_shell/command
   if [ "$TERM_CMD" ]; then
-   $REGTOOL -s set $DRIVE_KEY/cygwin_$this_shell/command/ \"$TERM_CMD $SHELL_CMD\"
+   $REGTOOL -s set $DRIVE_KEY/cygwin_$this_shell/command/ \"$TERM_CMD $SHELL_EXE $SHELL_CMD\"
   else
    # Windows doesn't like command keys starting with spaces
-   $REGTOOL -s set $DRIVE_KEY/cygwin_$this_shell/command/ \"$SHELL_CMD\"
+   $REGTOOL -s set $DRIVE_KEY/cygwin_$this_shell/command/ \"$SHELL_EXE $SHELL_CMD\"
   fi
  else
   echo $0 Warning: Not overriding existing entry
@@ -348,10 +350,10 @@ if [ $ACTION = i ]; then
   $REGTOOL -s set $DIR_KEY/cygwin_$this_shell/ \"$ACCEL\"
   $REGTOOL add $DIR_KEY/cygwin_$this_shell/command
   if [ "$TERM_CMD" ]; then
-   $REGTOOL -s set $DIR_KEY/cygwin_$this_shell/command/ \"$TERM_CMD $SHELL_CMD\"
+   $REGTOOL -s set $DIR_KEY/cygwin_$this_shell/command/ \"$TERM_CMD $SHELL_EXE $SHELL_CMD\"
   else
    # Windows doesn't like command keys starting with spaces
-   $REGTOOL -s set $DIR_KEY/cygwin_$this_shell/command/ \"$SHELL_CMD\"
+   $REGTOOL -s set $DIR_KEY/cygwin_$this_shell/command/ \"$SHELL_EXE $SHELL_CMD\"
   fi
  else
   echo $0 Warning: Not overriding existing entry


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