Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-01-19 17:59:10 +0300
committerCorinna Vinschen <corinna@vinschen.de>2011-01-19 17:59:10 +0300
commit9b68968b21886527163744407be85c6892c14021 (patch)
treecb76da493f3d09f17fdbff3560f59ec40d978ab7 /winsup/cygwin/spawn.cc
parent1393f63206ee9bd9e5452eb5fcd6fad4b8e46e4e (diff)
* spawn.cc (av::fixup): Reenable #! handling for all exec functions.
Return ENOEXEC in !p_type_exec case only for unrecognized files. Fix comment formatting.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc32
1 files changed, 13 insertions, 19 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 4575d7bb3..5f97f41e0 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -1066,13 +1066,6 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext,
/* ERROR_FILE_INVALID indicates very likely an empty file. */
if (GetLastError () == ERROR_FILE_INVALID)
{
- if (!p_type_exec)
- {
- /* Not called from exec[lv]p. Just leave. */
- debug_printf ("zero length file.");
- set_errno (ENOEXEC);
- return -1;
- }
debug_printf ("zero length file, treat as script.");
goto just_shell;
}
@@ -1105,14 +1098,6 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext,
}
}
- if (!p_type_exec)
- {
- /* Not called from exec[lv]p. Don't try to treat as script. */
- debug_printf ("%s is not a valid executable", real_path.get_win32 ());
- set_errno (ENOEXEC);
- return -1;
- }
-
debug_printf ("%s is possibly a script", real_path.get_win32 ());
ptr = buf;
@@ -1128,10 +1113,11 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext,
for (ptr = pgm = namebuf; *ptr; ptr++)
if (!arg1 && (*ptr == ' ' || *ptr == '\t'))
{
- /* Null terminate the initial command and step over any additional white
- space. If we've hit the end of the line, exit the loop. Otherwise,
- we've found the first argument. Position the current pointer on the
- last known white space. */
+ /* Null terminate the initial command and step over any
+ additional white space. If we've hit the end of the
+ line, exit the loop. Otherwise, we've found the first
+ argument. Position the current pointer on the last known
+ white space. */
*ptr = '\0';
char *newptr = ptr + 1;
newptr += strspn (newptr, " \t");
@@ -1146,6 +1132,14 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext,
just_shell:
if (!pgm)
{
+ if (!p_type_exec)
+ {
+ /* Not called from exec[lv]p. Don't try to treat as script. */
+ debug_printf ("%s is not a valid executable",
+ real_path.get_win32 ());
+ set_errno (ENOEXEC);
+ return -1;
+ }
if (ascii_strcasematch (ext, ".com"))
break;
pgm = (char *) "/bin/sh";