Skip to content

Conversation

@xwang1498
Copy link
Contributor

@xwang1498 xwang1498 commented Jul 18, 2025

Because most of the heavy lifting is done in awk, we actually don't need any bash-specific features to run prettyping. Making prettyping work on any posix-compatible shell will extend this great program's reach even further!

This PR builds on the work done in PR #44 , and therefore supersedes and closes #44 and closes #40.

Tested on various shells, including:

  • bash 3.2
  • bash 5.3
  • dash 0.5.12
  • ksh 93u+ 2021-08-01
  • ksh 93u+m 1.0.10
  • Busybox ash v1.36.1
  • Almquist shell (FreeBSD default)

Tested on various operating systems, including:

Implementation notes, which may be interesting while reviewing this PR:

  • Posix sh doesn't support arrays, but we can imitate them by working on the psuedo-array $@.
  • When parsing arguments for ping, we don't need to track them in a separate array, but can just append the non-processed ones to the end of $@. This way, they'll circle around to the front. For simplicity, parse them globally rather than inside of parse_arguments function (which would have its own $@).
  • Notes from PR better handling of SIGINT / Ctrl-C #44 apply re. signal handling.
  • Some shells (dash) interrupt read with the SIGWINCH, others do not. So we need to restart read if it was interrupted by SIGWINCH, but not if the input is finished. I added a SIGWINCH test case to mockping.sh.

This change ignores SIGINT only for the pipeline elements downstream of ping. This way ping will correctly receive the SIGINT, print its summary and cleanly exit, and then downstream elements will cleanly close afterwards.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doen't respond to SIGINT (ctrl+c)

1 participant