From: "Vadim (vadcx)" <[email protected]>

---
 src/chere | 260 +++++++++++++++++++++++++++---------------------------
 src/xhere |  17 ++--
 2 files changed, 138 insertions(+), 139 deletions(-)

diff --git a/src/chere b/src/chere
index 6ba2425..5b71d7e 100755
--- a/src/chere
+++ b/src/chere
@@ -163,19 +163,19 @@ check_requirements()
 {
  # Quick check of common utilities (from sh-utils, cygwin, textutils packages)
  if [ ! -x /bin/uname ] || [ ! -x /bin/cygpath ] || [ ! -x /bin/id ] || [ ! -x 
/bin/wc ] || [ ! -x /bin/sed ] ; then
-  echo $0 Error: uname / id / cygpath / wc / sed not found
+  echo "$0 Error: uname / id / cygpath / wc / sed not found"
   echo
   echo These tools are required for correct operation.
-  echo $0: Aborting
+  echo "$0: Aborting"
   exit
  fi
 
  # Check we have regtool (from cygwin package)
  if [ ! -x /bin/regtool ]; then
-  echo $0 Error: /bin/regtool not found
+  echo "$0 Error: /bin/regtool not found"
   echo
   echo You need regtool installed for this script to work.
-  echo $0: Aborting.
+  echo "$0: Aborting."
   exit
  fi
 
@@ -201,31 +201,29 @@ check_requirements()
 get_system_info()
 {
  # Check windows version and cygwin install directory
- VER=`uname -s`
- ID_USER=`id -nu`
+ VER=$(uname -s)
+ ID_USER=$(id -nu)
  RUN_EXE=""
- ASH_EXE=`cygpath -w /bin/sh`
- BASH_EXE=`cygpath -w /bin/bash`
+ ASH_EXE=$(cygpath -w /bin/sh)
+ BASH_EXE=$(cygpath -w /bin/bash)
 
- if [ `uname -m` = "i686" ]; then
+ if [ "$(uname -m)" = "i686" ]; then
    PFX=cygwin_
  else
    PFX=cygwin64_
  fi
 
- if [ -x /bin/which ]; then
-  # Enable prepending of run.exe if we can find it.
-  # I'm assuming run has been placed in the path.
+ # Enable prepending of run.exe if we can find it.
+ # I'm assuming run has been placed in the path.
 
-  # We did this because run.exe was packaged in X-startup-scripts.
-  # It is now in its own package and part of base.
-  # However, continue to check for it in this way.
+ # We did this because run.exe was packaged in X-startup-scripts.
+ # It is now in its own package and part of base.
+ # However, continue to check for it in this way.
 
-  RUN_EXE=`which run.exe 2>/dev/null`
-  if [ -n "$RUN_EXE" ]; then
-   # Convert to windows path
-   RUN_EXE=`cygpath -w "$RUN_EXE"`
-  fi
+ RUN_EXE=$(command -v run.exe 2>/dev/null)
+ if [ -n "$RUN_EXE" ]; then
+  # Convert to windows path
+  RUN_EXE=$(cygpath -w "$RUN_EXE")
  fi
 
  # Identify the registry keys for each OS and desired set of users
@@ -267,9 +265,9 @@ get_system_info()
 #  DRIVE_BG_KEY_CR - and the context menu for the drive background
 set_for_user()
 {
- if [ $1 = i ]; then
+ if [ "$1" = i ]; then
   # Set for install
-  if [ $2 = f ]; then
+  if [ "$2" = f ]; then
    DIR_KEY=$DIR_KEY_CU
    DIR_BG_KEY=$DIR_BG_KEY_CU
    DRIVE_KEY=$DRIVE_KEY_CU
@@ -284,11 +282,11 @@ set_for_user()
   fi
  else
   # Set for uninstall
-  if [ $2 = t ]; then
+  if [ "$2" = t ]; then
    # Don't remove HKCU entries
    DRIVE_KEYS="$DRIVE_KEY_CR $DRIVE_BG_KEY_CR"
    DIR_KEYS="$DIR_KEY_CR $DIR_BG_KEY_CR"
-  elif [ $2 = f ]; then
+  elif [ "$2" = f ]; then
    # Don't remove HKCR entries
    DRIVE_KEYS="$DRIVE_KEY_CU $DRIVE_BG_KEY_CU"
    DIR_KEYS="$DIR_KEY_CU $DIR_BG_KEY_CU"
@@ -305,7 +303,7 @@ set_for_user()
 #  ID_USER - current user
 get_shell_from_passwd()
 {
- getent passwd $ID_USER | sed -n "s?.*:/bin/\(.*\)?\1?gp"
+ getent passwd "$ID_USER" | sed -n "s?.*:/bin/\(.*\)?\1?gp"
 }
 
 # Identifies the terminal installed for the named shell
@@ -321,13 +319,13 @@ find_term_of_installed_shell()
  # use sed to strip everything except known terminals
  # construct the regexp of known terminals from KNOWN_TERMS
  # add command as well to pick up on 9x
- TERM_REGEXP=`echo $KNOWN_TERMS command | sed 's/ \+/\\\\|/g'`
- KEY_VALUE=`$REGTOOL_ get $DIR_KEY/$PFX$1/command/ | sed 
"s/.*\($TERM_REGEXP\).*/\1/g"`
+ TERM_REGEXP=$(echo "$KNOWN_TERMS command" | sed 's/ \+/\\\\|/g')
+ KEY_VALUE=$($REGTOOL_ get "$DIR_KEY/$PFX$1/command/" | sed 
"s/.*\($TERM_REGEXP\).*/\1/g")
 
  if [ "$KEY_VALUE" = "command" ]; then
   KEY_VALUE=cmd
  fi
- echo $KEY_VALUE
+ echo "$KEY_VALUE"
 }
 
 # Setup to install for a particular terminal
@@ -502,34 +500,34 @@ setup_for_shell()
        CPH_DESC="Cygwin Prompt Here"
 
        # Extra check before installing passwd
-       ge_shell=`get_shell_from_passwd`
+       ge_shell=$(get_shell_from_passwd)
        if [ -z "$ge_shell" ]; then
         if [ $FORCE = t ]; then
-         echo $0 Warning: login shell has not been set for user $ID_USER
+         echo "$0 Warning: login shell has not been set for user '$ID_USER'"
          echo
          echo This is required for the runtime context menu item to work.
          echo See cygwin documentation on how to set the login shell.
         else
-         echo $0 Error: login shell has not been set for user $ID_USER
+         echo "$0 Error: login shell has not been set for user '$ID_USER'"
          echo
          echo This is required for the runtime context menu item to work.
          echo See cygwin documentation on how to set the login shell.
-         echo Use -f to install anyway.
+         echo "Use -f to install anyway."
          exit
         fi
        fi;;
   * )
-       echo $0 Error: Unknown shell $1
+       echo "$0 Error: Unknown shell '$1'"
        echo
        echo Supported shells:
-       echo $KNOWN_SHELLS
+       echo "$KNOWN_SHELLS"
        echo
-       echo Use -h for help
+       echo "Use -h for help"
        exit;;
  esac
 
  # Uninstall string should indicate 64 or 32 bit cygwin entry
- if [ `uname -m` = "i686" ]; then
+ if [ "$(uname -m)" = "i686" ]; then
   CPH_DESC+=" (x86)"
  else
   CPH_DESC+=" (x86_64)"
@@ -561,20 +559,20 @@ build_start_cmd()
 {
  local TERM_WIN_EXE XHERE
  # TERM_EXE needs to be called by a windows path, even from run.exe
- TERM_WIN_EXE=`cygpath -w "$TERM_EXE"`
- if [ $3 = 1 ]; then
+ TERM_WIN_EXE=$(cygpath -w "$TERM_EXE")
+ if [ "$3" = 1 ]; then
   # METHOD 1 - invoke term and shell directly from the registry
-  if [ $1 != cmd ]; then
+  if [ "$1" != cmd ]; then
    if [ -n "$RUN_EXE" ]; then
     START_CMD="$RUN_EXE $RUN_ARGS $TERM_WIN_EXE $TERM_ARGS -e $SHELL_EXE"
    else
     START_CMD="$TERM_WIN_EXE $TERM_ARGS -e $SHELL_EXE"
    fi
-  elif [ $2 != cmd ]; then
+  elif [ "$2" != cmd ]; then
    # With cmd (term), the shell executable needs to be converted
    # to a windows path
    # With cmd, we ignore TERM_CMD.
-   START_CMD=`cygpath -w "$SHELL_EXE"`
+   START_CMD=$(cygpath -w "$SHELL_EXE")
   else
    # term and shell are cmd
    START_CMD=$SHELL_EXE
@@ -582,26 +580,26 @@ build_start_cmd()
  else
   # METHOD 2 - invoke xhere from the registry
   XHERE="/bin/xhere"
-  if [ $2 = cmd ]; then
+  if [ "$2" = cmd ]; then
    # Clear XHERE for when running command from rxvt/xterm
    XHERE="";
-  elif [ $2 = passwd ]; then
+  elif [ "$2" = passwd ]; then
    # Have XHERE do the call rather than bung it in the registry
    SHELL_EXE="/etc/passwd"
   fi
 
-  if [ $1 != cmd ]; then
+  if [ "$1" != cmd ]; then
    if [ -n "$RUN_EXE" ]; then
     START_CMD="$RUN_EXE $RUN_ARGS $TERM_WIN_EXE $TERM_ARGS -e $XHERE 
$SHELL_EXE"
    else
     START_CMD="$TERM_WIN_EXE $TERM_ARGS -e $XHERE $SHELL_EXE"
    fi
-   if [ $2 != cmd ]; then
+   if [ "$2" != cmd ]; then
     SHELL_CMD="\\\"%L\\\""
     SHELL_BG_CMD="\\\"%V\\\""
    fi
-  elif [ $2 != cmd ]; then
-   START_CMD="`cygpath -w \"$BASH_EXE\"`"
+  elif [ "$2" != cmd ]; then
+   START_CMD="$(cygpath -w "$BASH_EXE")"
    SHELL_CMD="-c \\\"$XHERE $SHELL_EXE '%L'\\\""
    SHELL_BG_CMD="-c \\\"$XHERE $SHELL_EXE '%V'\\\""
   else
@@ -619,15 +617,15 @@ build_start_cmd()
 create_registry_key()
 {
  local KEY_ELEMENTS CUR_KEY
-  KEY_ELEMENTS=`echo $1 | sed "s?/? ?g"`
+  KEY_ELEMENTS="${1//\// }" # replace forward slash with space
   CUR_KEY=
   for elem in $KEY_ELEMENTS; do
    CUR_KEY=$CUR_KEY/$elem
-   if ! $REGTOOL_ check $CUR_KEY 2>/dev/null ; then
+   if ! $REGTOOL_ check "$CUR_KEY" 2>/dev/null ; then
     # elem not present, so add it
-    if ! $REGTOOL add $CUR_KEY ; then
-     echo $0 Error: Hive not writable
-     echo $0: Aborting.
+    if ! $REGTOOL add "$CUR_KEY" ; then
+     echo "$0 Error: Hive not writable"
+     echo "$0: Aborting."
      exit
     fi
    fi
@@ -640,13 +638,13 @@ remove_registry_key()
 {
  local CUR_KEY ENTRIES
  CUR_KEY=$1
- if $REGTOOL_ check $CUR_KEY 2> /dev/null; then
+ if $REGTOOL_ check "$CUR_KEY" 2> /dev/null; then
   while [ -n "$CUR_KEY" ]; do
-   ENTRIES=`$REGTOOL_ list $CUR_KEY | wc -l`
-   if [ $ENTRIES = "0" ] || ( [ $ENTRIES = "1" ] && [ $PRINT = t ] ); then
+   ENTRIES=$($REGTOOL_ list "$CUR_KEY" | wc -l)
+   if [ "$ENTRIES" = "0" ] || ( [ "$ENTRIES" = "1" ] && [ "$PRINT" = t ] ); 
then
     # Remove empty key
-    $REGTOOL remove $CUR_KEY
-    CUR_KEY=`echo $CUR_KEY | sed "s?/[^/]*\\$??g"`
+    $REGTOOL remove "$CUR_KEY"
+    CUR_KEY=$(echo "$CUR_KEY" | sed "s?/[^/]*\\$??g")
    else
     # Abort
     CUR_KEY=
@@ -668,18 +666,18 @@ read_chere_registry_keys()
 {
  local FOR_WHO=""
  for shell in $KNOWN_SHELLS; do
-  echo --- $shell keys ---
+  echo "--- $shell keys ---"
   #### Directory entries ####
   FOR_WHO="(all users)"
   for dir in $DIR_KEY_CR $DIR_KEY_CU ; do
-   if $REGTOOL_ check $dir/$PFX$shell 2> /dev/null; then
-    echo Directory menu item $FOR_WHO
-    $REGTOOL get $dir/$PFX$shell/
+   if $REGTOOL_ check "$dir/$PFX$shell" 2> /dev/null; then
+    echo "Directory menu item $FOR_WHO"
+    $REGTOOL get "$dir/$PFX$shell/"
     echo
    fi
-   if $REGTOOL_ check $dir/$PFX$shell/command 2> /dev/null; then
-    echo Directory command $FOR_WHO
-    $REGTOOL get $dir/$PFX$shell/command/
+   if $REGTOOL_ check "$dir/$PFX$shell/command" 2> /dev/null; then
+    echo Directory command "$FOR_WHO"
+    $REGTOOL get "$dir/$PFX$shell/command/"
     echo
    fi
    FOR_WHO="(current user)"
@@ -687,55 +685,55 @@ read_chere_registry_keys()
   #### Directory background entries ####
   FOR_WHO="(all users)"
   for dir in $DIR_BG_KEY_CR $DIR_BG_KEY_CU ; do
-   if $REGTOOL_ check $dir/$PFX$shell 2> /dev/null; then
-    echo Directory background menu item $FOR_WHO
-    $REGTOOL get $dir/$PFX$shell/
+   if $REGTOOL_ check "$dir/$PFX$shell" 2> /dev/null; then
+    echo "Directory background menu item $FOR_WHO"
+    $REGTOOL get "$dir/$PFX$shell/"
     echo
    fi
-   if $REGTOOL_ check $dir/$PFX$shell/command 2> /dev/null; then
-    echo Directory background command $FOR_WHO
-    $REGTOOL get $dir/$PFX$shell/command/
+   if $REGTOOL_ check "$dir/$PFX$shell/command" 2> /dev/null; then
+    echo "Directory background command $FOR_WHO"
+    $REGTOOL get "$dir/$PFX$shell/command/"
     echo
    fi
    FOR_WHO="(current user)"
   done
   #### Drive entries ####
   FOR_WHO="(all users)"
-  for drive in $DRIVE_KEY_CR $DRIVE_KEY_CU ; do
-   if $REGTOOL_ check $drive/$PFX$shell 2> /dev/null; then
-    echo Drive menu item $FOR_WHO
-    $REGTOOL get $drive/$PFX$shell/
+  for drive in "$DRIVE_KEY_CR" "$DRIVE_KEY_CU" ; do
+   if $REGTOOL_ check "$drive/$PFX$shell" 2> /dev/null; then
+    echo "Drive menu item $FOR_WHO"
+    $REGTOOL get "$drive/$PFX$shell/"
     echo
    fi
-   if $REGTOOL_ check $drive/$PFX$shell/command 2> /dev/null; then
-    echo Drive command $FOR_WHO
-    $REGTOOL get $drive/$PFX$shell/command/
+   if $REGTOOL_ check "$drive/$PFX$shell/command" 2> /dev/null; then
+    echo "Drive command $FOR_WHO"
+    $REGTOOL get "$drive/$PFX$shell/command/"
     echo
    fi
    FOR_WHO="(current user)"
   done
   #### Drive background entries ####
   FOR_WHO="(all users)"
-  for drive in $DRIVE_BG_KEY_CR $DRIVE_BG_KEY_CU ; do
-   if $REGTOOL_ check $drive/$PFX$shell 2> /dev/null; then
-    echo Drive background menu item $FOR_WHO
-    $REGTOOL get $drive/$PFX$shell/
+  for drive in "$DRIVE_BG_KEY_CR" "$DRIVE_BG_KEY_CU" ; do
+   if $REGTOOL_ check "$drive/$PFX$shell" 2> /dev/null; then
+    echo "Drive background menu item $FOR_WHO"
+    $REGTOOL get "$drive/$PFX$shell/"
     echo
    fi
-   if $REGTOOL_ check $drive/$PFX$shell/command 2> /dev/null; then
-    echo Drive background command $FOR_WHO
-    $REGTOOL get $drive/$PFX$shell/command/
+   if $REGTOOL_ check "$drive/$PFX$shell/command" 2> /dev/null; then
+    echo "Drive background command $FOR_WHO"
+    $REGTOOL get "$drive/$PFX$shell/command/"
     echo
    fi
    FOR_WHO="(current user)"
   done
   #### UnInstall entries ####
-  if $REGTOOL_ check $UINST_KEY/$PFX$shell 2> /dev/null; then
+  if $REGTOOL_ check "$UINST_KEY/$PFX$shell" 2> /dev/null; then
     echo Uninstall description
-    $REGTOOL get $UINST_KEY/$PFX$shell/DisplayName
+    $REGTOOL get "$UINST_KEY/$PFX$shell/DisplayName"
     echo
     echo Uninstall command
-    $REGTOOL get $UINST_KEY/$PFX$shell/UnInstallString
+    $REGTOOL get "$UINST_KEY/$PFX$shell/UnInstallString"
     echo
   fi
   echo
@@ -792,21 +790,21 @@ install_context_menu()
 create_uninstall_item()
 {
  # Add uninstall registry entry
- if [ $FORCE = t ] || ! $REGTOOL_ check $1 2> /dev/null ; then
+ if [ $FORCE = t ] || ! $REGTOOL_ check "$1" 2> /dev/null ; then
   # Actually, should create an .inf so windows can get rid of the menu entries
   # even after the cygwin directory is wiped :(
-  if $REGTOOL add $1 ; then
-   $REGTOOL -s set $1/DisplayName \"$CPH_DESC\"
-   $REGTOOL -s set $1/UnInstallString \"$ASH_EXE -c \\\"PATH=/bin /bin/chere 
$UINST_ARG -u -s $2\\\"\"
+  if $REGTOOL add "$1" ; then
+   $REGTOOL -s set "$1/DisplayName" "\"$CPH_DESC\""
+   $REGTOOL -s set "$1/UnInstallString" \"$ASH_EXE -c \\\"PATH=/bin /bin/chere 
$UINST_ARG -u -s $2\\\"\"
   else
-   echo $0 Error: Couldn\'t modify HKLM hive.
-   echo Control Panel uninstall will not be available.
+   echo "$0 Error: Couldn't modify HKLM hive."
+   echo "Control Panel uninstall will not be available."
   fi
  else
-  echo $0 Warning: Not overriding existing entry
+  echo "$0 Warning: Not overriding existing entry"
   echo
-  echo Entry for $2 already exists in the Registry uninstall section
-  echo Use -f to override existing key.
+  echo "Entry for '$2' already exists in the Registry uninstall section"
+  echo "Use -f to override existing key."
   echo
  fi
 }
@@ -884,30 +882,30 @@ uninstall()
 {
  for drive in $DRIVE_KEYS ; do
   # Check each key exists before attempting to remove it
-  if $REGTOOL_ check $drive/$PFX$1/command 2> /dev/null; then
-   if ! $REGTOOL remove $drive/$PFX$1/command ; then
-    echo $0 Error: Hive not writable.
-    echo $0: Aborting.
+  if $REGTOOL_ check "$drive/$PFX$1/command" 2> /dev/null; then
+   if ! $REGTOOL remove "$drive/$PFX$1/command" ; then
+    echo "$0 Error: Hive not writable."
+    echo "$0: Aborting."
     exit
    fi
   fi
 
-  if $REGTOOL_ check $drive/$PFX$1 2> /dev/null; then
-   $REGTOOL remove $drive/$PFX$1
+  if $REGTOOL_ check "$drive/$PFX$1" 2> /dev/null; then
+   $REGTOOL remove "$drive/$PFX$1"
   fi
  done
 
  for dir in $DIR_KEYS ; do
-  if $REGTOOL_ check $dir/$PFX$1/command 2> /dev/null; then
-   $REGTOOL remove $dir/$PFX$1/command
+  if $REGTOOL_ check "$dir/$PFX$1/command" 2> /dev/null; then
+   $REGTOOL remove "$dir/$PFX$1/command"
   fi
-  if $REGTOOL_ check $dir/$PFX$1 2> /dev/null; then
-   $REGTOOL remove $dir/$PFX$1
+  if $REGTOOL_ check "$dir/$PFX$1" 2> /dev/null; then
+   $REGTOOL remove "$dir/$PFX$1"
   fi
  done
 
- if $REGTOOL_ check $UINST_KEY/$PFX$1 2> /dev/null; then
-  $REGTOOL remove $UINST_KEY/$PFX$1
+ if $REGTOOL_ check "$UINST_KEY/$PFX$1" 2> /dev/null; then
+  $REGTOOL remove "$UINST_KEY/$PFX$1"
  fi
 }
 
@@ -922,7 +920,7 @@ REGTOOL_="regtool -w"
 KNOWN_TERMS="cmd rxvt mintty xterm urxvt"
 KNOWN_SHELLS="ash bash cmd dash fish mksh pdksh posh tcsh zsh passwd"
 
-ALL_USERS=unset
+ALL_USERS="unset"
 ACTION=nothing
 FRESHEN=f
 DO_WIN_UINST=t
@@ -964,7 +962,7 @@ do
     o ) USER_TERM_OPTIONS="$OPTARG";;
     e ) USER_MENU_TEXT="$OPTARG";;
     \? | h ) print_help; exit;;
-    v ) echo $0 version $VERSION; exit;;
+    v ) echo "$0 version $VERSION"; exit;;
   esac
 done
 
@@ -972,17 +970,17 @@ check_requirements
 get_system_info
 
 # if DISP set to env, make sure we set it to read from the environment
-if [ $DISP = env ]; then
+if [ "$DISP" = env ]; then
   DISP="%DISPLAY%"
 fi
 
-if [ $FRESHEN = t ]; then
+if [ "$FRESHEN" = t ]; then
 
  # If the user has specified -e, abort since this is not right
  if [ -n "$USER_MENU_TEXT" ]; then
-  echo "$0 error: You really don\'t want to freshen your existing entires,"
+  echo "$0 error: You really don't want to freshen your existing entires,"
   echo "          and set all the context menus to the same string of text."
-  echo $0: Aborting.
+  echo "$0: Aborting."
   exit
  fi
 
@@ -991,11 +989,11 @@ if [ $FRESHEN = t ]; then
  for user in f t; do
   set_for_user i $user
 
-  INSTALLED=`list_cygwin_registry_keys $DIR_KEY`
-  echo Updating shells $INSTALLED
+  INSTALLED=$(list_cygwin_registry_keys "$DIR_KEY")
+  echo "Updating shells $INSTALLED"
   for this_shell in $INSTALLED; do
-   this_term=`find_term_of_installed_shell $this_shell`
-   install $this_term $this_shell
+   this_term=$(find_term_of_installed_shell "$this_shell")
+   install "$this_term" "$this_shell"
   done
  done
 
@@ -1037,22 +1035,22 @@ elif [ $ACTION = u ]; then
 
  # Uninstall each shell
  for ushell in $UINST_SHELLS ; do
-  uninstall $ushell
+  uninstall "$ushell"
  done
 
  # Remove keys after we've cleared out our entries
  for key in $DRIVE_KEYS $DIR_KEYS ; do
-  remove_registry_key $key
+  remove_registry_key "$key"
  done
 
 fi
 
-if [ $READ = t ]; then
+if [ "$READ" = t ]; then
  # Print some useful information
- echo OS is $VER
- echo chere version $VERSION
+ echo "OS is $VER"
+ echo "chere version $VERSION"
  if [ -n "$RUN_EXE" ]; then
-  echo run.exe is available at $RUN_EXE
+  echo "run.exe is available at $RUN_EXE"
  fi
  echo
  read_chere_registry_keys
@@ -1061,15 +1059,15 @@ fi
 # If requested, list what is currently installed
 # Rely on the DIR key rather than UINST key,
 # since user may pass -m, or HKLM may not be writable
-if [ $LIST = t ]; then
-  echo Currently installed Cygwin Here shells \(all users\):
-  list_cygwin_registry_keys $DIR_KEY_CR
+if [ "$LIST" = t ]; then
+  echo "Currently installed Cygwin Here shells (all users):"
+  list_cygwin_registry_keys "$DIR_KEY_CR"
   echo
-  echo Currently installed Cygwin Here shells \(current user\):
-  list_cygwin_registry_keys $DIR_KEY_CU
+  echo "Currently installed Cygwin Here shells (current user):"
+  list_cygwin_registry_keys "$DIR_KEY_CU"
 fi
 
-if [ $FRESHEN = f ] && [ $ACTION = nothing ] && [ $LIST = f ] && [ $READ = f 
]; then
- echo $0: No action taken
+if [ "$FRESHEN" = f ] && [ "$ACTION" = nothing ] && [ "$LIST" = f ] && [ 
"$READ" = f ]; then
+ echo "$0: No action taken"
  print_help
 fi
diff --git a/src/xhere b/src/xhere
index 5c83085..7dd2375 100755
--- a/src/xhere
+++ b/src/xhere
@@ -35,10 +35,10 @@ SED=/bin/sed
 ID=/bin/id
 GETENT=/bin/getent
 
-if [ -z $1 ]; then
+if [ -z "$1" ]; then
  echo An argument is required, specifying the shell to invoke as a login shell
  exit
-elif [ $1 == -h ]; then
+elif [ "$1" == -h ]; then
  echo This script is not intended to be invoked from the command line. Try 
chere -h
  exit
 fi
@@ -49,7 +49,7 @@ export CHERE_INVOKING=true
 # Goto the desired directory.
 # This is necessary when the context menu is opened in the RH pane
 if [ ! -z "$2" ]; then
- CHERE_DIR=`$CYGPATH "$2"`
+ CHERE_DIR=$($CYGPATH "$2")
  NETWORK_PATH=/$CHERE_DIR
  if [ -d "$CHERE_DIR" ]; then
   cd "$CHERE_DIR"
@@ -61,9 +61,10 @@ if [ ! -z "$2" ]; then
 fi
 # If that doesn't exist then the current should be the desired directory
 
-if [ $1 = /etc/passwd ]; then
- user=`$ID -un`
- scmd=`$GETENT passwd $user | $SED -n "s?.*:\(.*\)?\1?gp"`
+if [ "$1" = /etc/passwd ]; then
+ user=$($ID -un)
+ scmd=$($GETENT passwd "$user" | $SED -n 's?.*:\(.*\)?\1?gp')
+ 
  set -- $scmd
 fi
 
@@ -71,8 +72,8 @@ fi
 # but only if we recognise the shell
 case $1 in 
  /bin/sh* | /bin/bash* | /bin/pdksh* | /bin/posh* | /bin/tcsh* | /bin/zsh*  | 
/bin/dash* | /bin/mksh* | /bin/fish* )
-    echo Starting $1;
+    echo "Starting '$1'";
     exec -l $1;;
  * )
-    echo Do not recognise $1;;
+    echo "Do not recognise '$1' as a shell";;
 esac
\ No newline at end of file
-- 
2.50.1

Reply via email to