coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fix for env-S-script.sh shebang len limitations


From: Pádraig Brady
Subject: fix for env-S-script.sh shebang len limitations
Date: Tue, 26 Jun 2018 00:47:54 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 24/06/18 23:49, Pádraig Brady wrote:
> I see a false failure in the new tests/misc/env-S-script.sh
> which is due to overflowing the shebang length limit
> depending on where one runs the test from.
> The limit on Linux is only 127 it seems :/
> https://www.in-ulm.de/~mascheck/various/shebang/#length
> 
> I'll come up with a way to skip the test if some sentinel
> value isn't passed through.

So rather than relying on shebangs that have various limitations,
the attached uses a wrapper script like:

cat <<\EOF > shebang
#!/bin/sh
# Execute a script as per 3 argument shebang
# but without length limits (127 on Linux for example).
script="$1"; shift
shebang=$(sed -n 's/^#!//p;q' < "$script")
interp=$(printf '%s' "$shebang" | cut -d' ' -f1)
rest=$(printf '%s' "$shebang" | cut -s -d' ' -f2-)
test "$rest" && exec "$interp" "$rest" "$script" "$@"
exec "$interp" "$script" "$@"
EOF
chmod a+x shebang


Which you then use like:

./shebang ./env1 ...


However I'm not convinced we're testing anything more
than what's in env-S.pl here?
I.E. we're not actually relying on shebang processing
as it's too inconsistent.

So I'm inclined to just remove the test?

cheers,
Pádraig

Attachment: env-S-test-fix.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]