1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-22 23:26:47 +02:00

dsv (setup): make sure file ends with a newline, so that we can "read" it

This commit is contained in:
Werner Almesberger 2010-11-30 19:27:59 -03:00
parent be269982f3
commit f207be6671

34
dsv/dsv
View File

@ -102,20 +102,26 @@ setup()
echo "$n: not found" 2>&1
continue
fi
while read line; do
[ "$line" = "${line###}" ] || continue
tmp=`echo "$line" | awk '/^[^\t ]/ { print $1 }'`
tail=`echo "$line" | sed 's/^[^\t ]*[\t ]*//'`
if [ -z "$tmp" ]; then
[ -z "$tail" ] || value="$value $tail"
else
set_value
tag=$tmp
value=$tail
fi
done <"$n"
set_value
eof
#
# "read" doesn't recognize lines that don't end with a newline.
# The cat-sed hack below works around this problems.
#
cat -E "$n" | sed 's/[^$]$/&\n/;s/$$//' | {
while read line; do
[ "$line" = "${line###}" ] || continue
tmp=`echo "$line" | awk '/^[^\t ]/ { print $1 }'`
tail=`echo "$line" | sed 's/^[^\t ]*[\t ]*//'`
if [ -z "$tmp" ]; then
[ -z "$tail" ] || value="$value $tail"
else
set_value
tag=$tmp
value=$tail
fi
done
set_value
eof
}
done
}