2013-01-19 00:09:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This file is part of util-linux.
|
|
|
|
#
|
|
|
|
# This file is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This file is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
2014-02-16 23:54:14 +00:00
|
|
|
TS_TOPDIR="${0%/*}/../.."
|
2013-01-19 00:09:00 +00:00
|
|
|
TS_DESC="line"
|
|
|
|
|
|
|
|
. $TS_TOPDIR/functions.sh
|
|
|
|
ts_init "$*"
|
|
|
|
|
2014-02-16 15:22:56 +00:00
|
|
|
ts_check_test_command "$TS_CMD_LINE"
|
2017-06-13 15:33:58 +02:00
|
|
|
ts_check_test_command "$TS_CMD_HEXDUMP"
|
2013-04-10 17:30:15 +02:00
|
|
|
|
2017-06-13 15:33:58 +02:00
|
|
|
ts_log '# usually behave like "head -n 1"'
|
2013-01-19 00:09:00 +00:00
|
|
|
printf "a\nb\n" |
|
2019-08-30 15:50:07 +02:00
|
|
|
$TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
|
2015-12-03 01:42:28 +01:00
|
|
|
echo "ret: $?" >> $TS_OUTPUT
|
|
|
|
|
2017-06-13 15:33:58 +02:00
|
|
|
ts_log '# never consume more than one line'
|
2015-12-03 01:42:28 +01:00
|
|
|
printf "1\n2\n" |
|
2019-08-30 15:50:07 +02:00
|
|
|
($TS_CMD_LINE && $TS_CMD_LINE) >> $TS_OUTPUT 2>> $TS_ERRLOG
|
2015-12-03 01:42:28 +01:00
|
|
|
echo "ret: $?" >> $TS_OUTPUT
|
|
|
|
|
2017-06-13 15:33:58 +02:00
|
|
|
ts_log '# add a newline'
|
|
|
|
printf "abc" |
|
2019-08-30 15:50:07 +02:00
|
|
|
$TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
|
2017-06-13 15:33:58 +02:00
|
|
|
echo "ret: $?" >> $TS_OUTPUT
|
|
|
|
|
|
|
|
ts_log '# print one newline on empty input'
|
|
|
|
printf "" |
|
2019-08-30 15:50:07 +02:00
|
|
|
$TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
|
2017-06-13 15:33:58 +02:00
|
|
|
echo "ret: $?" >> $TS_OUTPUT
|
|
|
|
|
|
|
|
ts_log '# add a newline, return 1 when EOF'
|
|
|
|
(printf "xyz" && cat </dev/null) |
|
2019-08-30 15:50:07 +02:00
|
|
|
$TS_CMD_LINE >> $TS_OUTPUT 2>> $TS_ERRLOG
|
2017-06-13 15:33:58 +02:00
|
|
|
echo "ret: $?" >> $TS_OUTPUT
|
|
|
|
|
|
|
|
ts_log '# print one newline on empty input, return 1 when EOF'
|
2019-08-30 15:50:07 +02:00
|
|
|
$TS_CMD_LINE </dev/null >> $TS_OUTPUT 2>> $TS_ERRLOG
|
2015-12-03 01:42:28 +01:00
|
|
|
echo "ret: $?" >> $TS_OUTPUT
|
2013-01-19 00:09:00 +00:00
|
|
|
|
2017-06-13 15:33:58 +02:00
|
|
|
ts_log '# large line of zero bytes'
|
|
|
|
dd if=/dev/zero bs=1k count=1k 2>/dev/null |
|
2019-08-30 15:50:07 +02:00
|
|
|
$TS_CMD_LINE line | $TS_CMD_HEXDUMP -C >> $TS_OUTPUT 2>> $TS_ERRLOG
|
2017-06-13 15:33:58 +02:00
|
|
|
echo "ret: $?" >> $TS_OUTPUT
|
|
|
|
|
2013-01-19 00:09:00 +00:00
|
|
|
ts_finalize
|