]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
scripts: Fix reading binary data in check-interpreters
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 3 Nov 2022 20:10:18 +0000 (20:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 3 Nov 2022 20:10:18 +0000 (20:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/check-interpreters

index 4565756ca1cd489d02590c41d6d57b720155a63c..ba7e882e62fb818a91c8bf8911d3664639b5eba6 100644 (file)
@@ -38,14 +38,15 @@ main() {
 
        # Find all executable files
        for file in $(find "${buildroot}" -type f -perm /111 | sort); do
-               local first_line="$(grep -q "^#!" "${file}" && head -n1 "${file}")"
+               local shebang="$(head -c2 "${file}")"
 
                # Skip files that are not scripts
-               if [ "${first_line:0:2}" != "#!" ]; then
+               if [ "${shebang:0:2}" != "#!" ]; then
                        continue
                fi
 
-               local interpreter="${first_line:2}"
+               local interpreter="$(head -n1 "${file}")"
+               interpreter="${interpreter:2}"
 
                case "${interpreter}" in
                        # Interpreters in /usr/local are illegal