This is the mail archive of the 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.
>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.,

      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.


--- 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;;
   rxvt )
-	TERM_CMD="$CYG_DIR/bin/rxvt.exe -e"
+	TERM_CMD="/bin/rxvt.exe -e"
   xterm )
-	TERM_CMD="$CYG_DIR/bin/xterm.exe -e"
+	TERM_CMD="/bin/xterm.exe -e"
   * )
 	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\\\""
 	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\\\"";
 	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\\\""
 	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\\\""
 	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\\\""
 	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
- 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
@@ -322,6 +322,8 @@ if [ $ACTION = i ]; then
+ [ -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\"
    # 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\"
   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\"
    # 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\"
   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]