~sircmpwn/ctools

fbf17d92f5ed1c38983f73df912f051ad0f9ef2d — Gabor Koszegi 3 months ago f2d5838 master
tee: Fix missing output file truncation
2 files changed, 7 insertions(+), 2 deletions(-)

M src/tee.c
M test/tee
M src/tee.c => src/tee.c +1 -1
@@ 74,7 74,7 @@ cleanup:
int
main(int argc, char *argv[])
{
	int aflag = 0;
	int aflag = O_TRUNC;

	char opt;
	while ((opt = getopt(argc, argv, "ai")) != -1) {

M test/tee => test/tee +6 -1
@@ 10,7 10,12 @@ should_handle_zero_file() (
should_handle_one_file() (
	stdout="$(echo "tesT 1ine" | tee "$TMPDIR"/one-file)"
	res="$(cat "$TMPDIR"/one-file)"
	[ "$res" = "tesT 1ine" ] && [ "$res" = "$stdout" ]
	[ "$res" = "tesT 1ine" ] && [ "$res" = "$stdout" ] || return 1

	echo "a really long line for test" >"$TMPDIR"/one-file
	stdout="$(echo "shorter line" | tee "$TMPDIR"/one-file)"
	res="$(cat "$TMPDIR"/one-file)"
	[ "$res" = "shorter line" ] && [ "$res" = "$stdout" ]
)

should_handle_two_files() (