X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Subject: RE: Patch for bash to support PATHEXT in Windows Date: Thu, 6 Sep 2007 18:31:11 -0400 Message-ID: <31DDB7BE4BF41D4888D41709C476B657068AB51D@NIHCESMLBX5.nih.gov> In-Reply-To: <20070906191518.GC19860@ednor.casa.cgf.cx> From: "Buchbinder, Barry (NIH/NIAID) [E]" To: X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id l86MVNrF029054 Christopher Faylor wrote on Thursday, September 06, 2007 3:15 PM: > On Thu, Sep 06, 2007 at 01:12:19PM -0600, Eric Blake wrote: >> -----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. > > I'm impressed with the patch but I don't think it really adheres to > the philosophy of Cygwin or Linux. > > Also, the Cygwin DLL already has enough code to deal with extensions > specially. We're not going to add more and feed the "Cygwin is slow" > fodder. > > I really am sorry to have to reject the idea when the OP has already > gone to some effort but I just don't see this happening. > > cgf I don't understand what is the real problem. If I understand permissions correctly, all one has to do is to set them. Would something like the following work for you if you ran it periodically or once when you switch from MKS to cygwin? for F in $(echo $PATH | \ tr : \\n | \ grep -v -e '^\.\?$' ) do find $F \! -perm 777 -type f \( -iname \*.ksh -o -iname \*.sh \) -print0 2> /dev/null done | \ xargs -0r chmod -v 777 Good luck, - Barry -- 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/