Make add-shell correctly handle /etc/shells files that do not end with newlines

Fixes https://github.com/fish-shell/fish-shell/issues/77
This commit is contained in:
ridiculousfish 2012-07-22 16:59:08 -07:00
parent 261bf12c91
commit 56599621cc

View File

@ -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