aboutsummaryrefslogtreecommitdiffhomepage
path: root/build_tools
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-07-22 16:59:08 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-07-22 17:00:44 -0700
commit56599621ccfd06587eefff67b6713d428bcddbd0 (patch)
treec66c51d2c7a0e216b78033aee10bf4b4943e16a1 /build_tools
parent261bf12c91286ffca9fcb0bf761d6d1666359dc7 (diff)
Make add-shell correctly handle /etc/shells files that do not end with newlines
Diffstat (limited to 'build_tools')
-rwxr-xr-xbuild_tools/osx_package_scripts/add-shell11
1 files changed, 8 insertions, 3 deletions
diff --git a/build_tools/osx_package_scripts/add-shell b/build_tools/osx_package_scripts/add-shell
index 3544ebfc..d12fc062 100755
--- a/build_tools/osx_package_scripts/add-shell
+++ b/build_tools/osx_package_scripts/add-shell
@@ -21,7 +21,7 @@ tmpfile=${file}.tmp
set -o noclobber
trap "rm -f $tmpfile" EXIT
-
+
if ! cat $file > $tmpfile
then
cat 1>&2 <<EOF
@@ -31,11 +31,16 @@ EOF
exit 1
fi
+# Append a newline if it doesn't exist
+if [ "$(tail -c1 "$tmpfile"; echo x)" != $'\nx' ]; then
+ echo "" >> "$tmpfile"
+fi
+
for i
do
- if ! grep -q "^${i}$" $tmpfile
+ if ! grep -q "^${i}$" "$tmpfile"
then
- echo $i >> $tmpfile
+ echo $i >> "$tmpfile"
fi
done