cookbook/container/kvm: better handling of \r\n line endings.

This commit is contained in:
Avery Pennarun 2019-02-20 19:14:37 -05:00
commit 938c6c65c4

View file

@ -21,10 +21,15 @@ kvm \
-serial chardev:char0 \ -serial chardev:char0 \
-serial chardev:char1 \ -serial chardev:char1 \
-serial chardev:char2 >&2 -serial chardev:char2 >&2
read rv <$1.code || true fix_cr() {
[ -z "$rv" ] && exit 99 # serial devices use crlf (\r\n) as line
# endings instead of just lf (\n).
sed -e 's/\r//g'
}
rv=$(fix_cr <"$1.code")
[ -n "$rv" ] || exit 99
if [ "$rv" -eq 0 ]; then if [ "$rv" -eq 0 ]; then
sed -e 's/\r//g' "$1.out" >$3 fix_cr <"$1.out" >$3
echo "ok." >&2 echo "ok." >&2
else else
echo "kvm program returned error: $rv" >&2 echo "kvm program returned error: $rv" >&2