delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/07/30/09:41:33

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Tue, 30 Jul 2002 09:43:25 -0400
From: Jason Tishler <jason AT tishler DOT net>
Subject: RFC: sh -c implied .exe suffix patch
To: Cygwin <cygwin AT cygwin DOT com>
Mail-followup-to: Cygwin <cygwin AT cygwin DOT com>
Message-id: <20020730134324.GE1916@tishler.net>
MIME-version: 1.0
User-Agent: Mutt/1.4i

--Boundary_(ID_2oXi9YfIVNOYreVL/bIjkg)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
Content-disposition: inline

The attached patch, loosely inspired by a Cygwin specific patch to cp,
solves the following problem:

    $ ls -ld foo*
    drwxr-xr-x    2 jt       Domain U        0 Jul 30 09:15 foo
    -rwxr-xr-x    1 jt       Domain U    17924 Jul 26 15:10 foo.exe

    $ sh -c ./foo
    ./foo: not found

Note that bash does not have this problem:

    $ bash -c ./foo
    hello

After studying the source for ash, bash, and cygwin.  I understand why
it works for bash but not for ash.  Unfortunately, AFAICT, this problem
cannot be solved in the Cygwin DLL.  So, I decided to develop a ash
workaround.  With this patch, ash now behaves like bash for the above
test case:

    $ sh -c ./foo
    hello

Is the ash maintainer willing to accept this patch?

Thanks,
Jason

--Boundary_(ID_2oXi9YfIVNOYreVL/bIjkg)
Content-type: text/plain; charset=us-ascii; NAME=exec.c.diff
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=exec.c.diff

--- exec.c.orig	2002-07-29 16:00:41.000000000 -0400
+++ exec.c	2002-07-29 16:07:44.000000000 -0400
@@ -459,7 +459,22 @@ find_command(name, entry, printerr, path
                     (statb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))
                     entry->cmdtype = CMDNORMAL;
                 else
+#ifndef __CYGWIN__
                     entry->cmdtype = CMDUNKNOWN;
+#else
+		{
+		    char *name_exe = 0;
+		    name_exe = alloca(strlen(name) + 5);
+		    strcpy(name_exe, name);
+		    strcat(name_exe, ".exe");
+		    if (stat(name_exe, &statb) == 0 &&
+			S_ISREG(statb.st_mode) &&
+			(statb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))
+			entry->cmdtype = CMDNORMAL;
+		    else
+			entry->cmdtype = CMDUNKNOWN;
+		}
+#endif /* !__CYGWIN__ */
 		entry->u.index = -1;
 		return;
 	}


--Boundary_(ID_2oXi9YfIVNOYreVL/bIjkg)
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--Boundary_(ID_2oXi9YfIVNOYreVL/bIjkg)--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019