mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 06:15:54 +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
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user