mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
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:
parent
261bf12c91
commit
56599621cc
|
@ -21,7 +21,7 @@ tmpfile=${file}.tmp
|
||||||
set -o noclobber
|
set -o noclobber
|
||||||
|
|
||||||
trap "rm -f $tmpfile" EXIT
|
trap "rm -f $tmpfile" EXIT
|
||||||
|
|
||||||
if ! cat $file > $tmpfile
|
if ! cat $file > $tmpfile
|
||||||
then
|
then
|
||||||
cat 1>&2 <<EOF
|
cat 1>&2 <<EOF
|
||||||
|
@ -31,11 +31,16 @@ EOF
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Append a newline if it doesn't exist
|
||||||
|
if [ "$(tail -c1 "$tmpfile"; echo x)" != $'\nx' ]; then
|
||||||
|
echo "" >> "$tmpfile"
|
||||||
|
fi
|
||||||
|
|
||||||
for i
|
for i
|
||||||
do
|
do
|
||||||
if ! grep -q "^${i}$" $tmpfile
|
if ! grep -q "^${i}$" "$tmpfile"
|
||||||
then
|
then
|
||||||
echo $i >> $tmpfile
|
echo $i >> "$tmpfile"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user