Fix stdin recording (broken during pty refactor)

This commit is contained in:
Marcin Kulik
2022-05-07 16:16:53 +02:00
parent 2e83a89994
commit 0ba83391ef
2 changed files with 8 additions and 4 deletions

View File

@@ -74,9 +74,10 @@ def record(
return
while data:
n = os.write(pty_fd, data)
data = data[n:]
remaining_data = data
while remaining_data:
n = os.write(pty_fd, remaining_data)
remaining_data = remaining_data[n:]
if not pause_time:
assert start_time is not None

View File

@@ -82,7 +82,10 @@ bash -c "sleep 1; pkill -9 -n -f 'bash -c echo t3st'" &
asciinema rec -c 'bash -c "echo t3st; sleep 2; echo ok"' "${TMP_DATA_DIR}/4.cast"
# with stdin recording
asciinema rec --stdin -c 'bash -c "echo t3st; sleep 1; echo ok"' "${TMP_DATA_DIR}/5.cast"
echo "ls" | asciinema rec --stdin -c 'bash -c "sleep 1"' "${TMP_DATA_DIR}/5.cast"
cat "${TMP_DATA_DIR}/5.cast"
grep '"i", "ls\\n"' "${TMP_DATA_DIR}/5.cast"
grep '"o",' "${TMP_DATA_DIR}/5.cast"
# raw output recording
asciinema rec --raw -c 'bash -c "echo t3st; sleep 1; echo ok"' "${TMP_DATA_DIR}/6.raw"