Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Last active March 19, 2018 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kou1okada/45ac4f49a45af076faa00ecc3c96d40c to your computer and use it in GitHub Desktop.
Save kou1okada/45ac4f49a45af076faa00ecc3c96d40c to your computer and use it in GitHub Desktop.
Cygwin xhere patch for a problem about pathname that contains spaces.

A Problem which resolves with this patch

For example, if xhere called below parameters from cmd.exe,

C:\cygwin64\bin\mintty -e /bin/xhere /bin/bash "C:\Program Files"

xhere must recieve "$2" = "C:\Program Files". But currently xhere recieves "$2" = ""C:\Program Files"". :-(

Maybe this causes by argv parser of cygwin. This patch is a dirty and adhock hack for this problem.

Apply this patch

Run below commands:

apt-cyg install patch git
cd /tmp
git clone https://gist.githubusercontent.com/kou1okada/45ac4f49a45af076faa00ecc3c96d40c xhere.patch
cd xhere.patch
patch -b -p0 -d/ < xhere.patch

Relations

*** /bin/xhere.orig 2014-02-21 08:00:09.000000000 +0900
--- /bin/xhere 2016-10-06 17:51:16.504985300 +0900
***************
*** 35,40 ****
--- 35,46 ----
ID=/bin/id
GETENT=/bin/getent
+ if [[ ! -e "$2" && "${2::1}" = "${2: -1}" && ( "${2::1}" = "'" || "${2::1}" = '"' ) ]]; then
+ tmp=( "$@" )
+ tmp[1]="${2:1:-1}"
+ set -- "${tmp[@]}"
+ fi
+
if [ -z $1 ]; then
echo An argument is required, specifying the shell to invoke as a login shell
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment