summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-05-15 17:06:43 +0000
committerRoland McGrath <roland@gnu.org>1999-05-15 17:06:43 +0000
commit1a7967bea5c200bdfb747a71d87d75a4cb382ab9 (patch)
tree361514e373b085ab2bacccedaa152596895224e9
parent85d9e4d2a40458486f587fbffb20cd8ef912b8c7 (diff)
1999-05-15 Roland McGrath <roland@baalperazim.frob.com>
* hashexec.c (check_hashbang): Trim trailing blanks after interpreter argument.
-rw-r--r--exec/hashexec.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/exec/hashexec.c b/exec/hashexec.c
index 665724ad..4b8eae4f 100644
--- a/exec/hashexec.c
+++ b/exec/hashexec.c
@@ -1,5 +1,5 @@
/* GNU Hurd standard exec server, #! script execution support.
- Copyright (C) 1995, 96, 97, 98 Free Software Foundation, Inc.
+ Copyright (C) 1995, 96, 97, 98, 99 Free Software Foundation, Inc.
Written by Roland McGrath.
This file is part of the GNU Hurd.
@@ -151,20 +151,30 @@ check_hashbang (struct execdata *e,
interp = strsep (&p, " \t");
if (p)
- /* Skip remaining blanks, and the rest of the line is the argument. */
{
+ /* Skip remaining blanks, and the rest of the line is the argument. */
p += strspn (p, " \t");
arg = p;
len = interp_len - (arg - ibuf);
- }
- else
- /* There is no argument. */
- len = 0;
- if (len == 0)
- arg = NULL;
+ if (len == 0)
+ arg = NULL;
+ else
+ {
+ size_t i = len - 1;
+ /* Trim trailing blanks after the argument. */
+ while (arg[i] == ' ' || arg[i] == '\t')
+ --i;
+ arg[i] = '\0';
+ len = i + 2; /* Include the terminating null. */
+ }
+ }
else
- ++len; /* Include the terminating null. */
+ {
+ /* There is no argument. */
+ arg = NULL;
+ len = 0;
+ }
interp_len = strlen (interp) + 1;