Trim all whitespace between interpreter and arg

Multiple whitespace characters are allowed. This fixes Ubuntu's
/usr/sbin/invoke-rc.d, which has trailing whitespace after the
interpreter which we were treating as an arg.

PiperOrigin-RevId: 203802278
Change-Id: I0a6cdb0af4b139cf8abb22fa70351fe3697a5c6b
This commit is contained in:
Michael Pratt
2018-07-09 11:43:56 -07:00
committed by Shentubot
parent 5c88e6a15d
commit 0dedac637f
+2 -4
View File
@@ -66,7 +66,7 @@ func parseInterpreterScript(ctx context.Context, filename string, f *fs.File, ar
// Skip any whitespace before the interpeter.
line = bytes.TrimLeft(line, " \t")
// Linux only looks for a space or tab delimiting the interpreter and
// Linux only looks for spaces or tabs delimiting the interpreter and
// arg.
//
// execve(2): "On Linux, the entire string following the interpreter
@@ -77,9 +77,7 @@ func parseInterpreterScript(ctx context.Context, filename string, f *fs.File, ar
i = bytes.IndexAny(line, " \t")
if i >= 0 {
interp = line[:i]
if i+1 < len(line) {
arg = line[i+1:]
}
arg = bytes.TrimLeft(line[i:], " \t")
}
if string(interp) == "" {