X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <46E05113.6030004@byu.net> Date: Thu, 06 Sep 2007 13:12:19 -0600 From: Eric Blake Reply-To: cygwin AT cygwin DOT com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: mike-cygsub AT mmpintl DOT demon DOT co DOT uk, cygwin AT cygwin DOT com Subject: Re: Patch for bash to support PATHEXT in Windows References: loom DOT 20070809T175729-768 AT post DOT gmane DOT org <46E026B9 DOT 4060703 AT mmpintl DOT demon DOT co DOT uk> In-Reply-To: <46E026B9.4060703@mmpintl.demon.co.uk> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 A mailing list is more appropriate for this than me personally - http://cygwin.com/acronyms/#PPIOSPE According to Mike Parker on 9/6/2007 10:11 AM: > Eric; > > Apologies if you are not the "Volunteer BASH Maintainer"; if not can you > point me in the right direction to get it submitted properly? > > I have seen many postings about "default" extensions defined by PATHEXT. > I have done a patch to support this. > > e.g. > > export PATHEXT=".ksh;.sh" PATHEXT is a cmd.com feature, and does not have much precedence in Linux. > > will add file types .ksh (e.g. xx.ksh) and .sh as a found file. This is > personally helping me migrate away from MKS Korn Shell. > > The Patch > ============================================================================== > > > diff -Nur bash-3.2.postpatch/findcmd.c bash-3.2.new/findcmd.c > --- bash-3.2.postpatch/findcmd.c 2007-09-04 16:19:46.019666300 +0100 > +++ bash-3.2.new/findcmd.c 2007-09-06 13:40:19.172250000 +0100 > @@ -50,6 +50,7 @@ > static char *_find_user_command_internal __P((const char *, int)); > static char *find_user_command_internal __P((const char *, int)); > static char *find_user_command_in_path __P((const char *, char *, int)); > +static char *find_user_command_in_path_orig __P((const char *, char *, > int)); > static char *find_in_path_element __P((const char *, char *, int, int, > struct stat *)); > static char *find_absolute_program __P((const char *, int)); > > @@ -525,12 +526,55 @@ > FS_EXISTS: The first file found will do. > FS_NODIRS: Don't find any directories. > */ > + > +#define PATHEXT_SEP ";:" /* Separators for parsing PATHEXT */ I'd rather use just :, as in PATH, rather than defining PATHEXT_SEP; but that may imply also patching cygwin1.dll to treat PATHEXT similarly to PATH. > static char * > find_user_command_in_path (name, path_list, flags) > const char *name; > char *path_list; > int flags; > { > + char *found_file; > + char *pathext; > + char *file_type; > + char *trial_name; > + int name_length; > + SHELL_VAR *var; > + > +/* Use original lookup to find "name" and "name.exe" */ > + found_file = find_user_command_in_path_orig(name, path_list, flags); > + if(found_file) return (found_file); > + > +/* Not found, step through file types in PATHEXT */ > +/* PATHEXT follows the Windows format - e.g. ".ksh;.sh;.cmd" */ > + var = find_variable_internal("PATHEXT", 1); > + if(var) > + { > + pathext = strdup(value_cell(var)); > + name_length = strlen(name); > + file_type = strtok(pathext, PATHEXT_SEP); > + while(file_type) > + { > + trial_name = malloc(name_length + strlen(file_type) + 1); > + strcpy(trial_name, name); > + strcat(trial_name, file_type); > + found_file = find_user_command_in_path_orig(trial_name, > path_list, flags); > + free(trial_name); > + if(found_file) break; /* Found - break out of loop */ > + file_type = strtok((char *)NULL, PATHEXT_SEP); > + } > + free(pathext); > + } > + return (found_file); > + > +} > + > +static char * > +find_user_command_in_path_orig (name, path_list, flags) > + const char *name; > + char *path_list; > + int flags; > +{ > char *full_path, *path; > int path_index, name_len; > struct stat dotinfo; > > End Patch > ============================================================================== > > > Hope this helps > Thanks for the idea. However, I'm not sure I want to incorporate this into cygwin at this time, without more support from cygwin1.dll, or at least without more discussion on the list. - -- Don't work too hard, make some time for fun as well! Eric Blake ebb9 AT byu DOT net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG4FES84KuGfSFAYARAk7QAJ0bEfXqMAVbuqCTcLZWBd9Yx3i5/ACfY4X9 YoLzIK00vQclYtwDU7JfgSQ= =VC3V -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/