makepkg: ensure PKGBUILD does not contain CRLF characters

Do a simple check before sourcing the file to ensure we are a valid bash
script.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2008-12-06 23:32:34 -06:00
parent 69be73f68c
commit 818fae320f
1 changed files with 6 additions and 0 deletions

View File

@ -1354,6 +1354,12 @@ if [ ! -f "$BUILDSCRIPT" ]; then
# PKGBUILD passed through a pipe
BUILDSCRIPT=/dev/stdin
fi
else
crlftest=$(file $BUILDSCRIPT | grep -F 'CRLF' || true)
if [ "$crlftest" != "" ]; then
error "$(gettext "%s contains CRLF characters and cannot be sourced.")" "$BUILDSCRIPT"
exit 1
fi
fi
source "$BUILDSCRIPT"