On Wed, 27 Aug 2025 at 18:41, Oğuz <oguzismailuy...@gmail.com> wrote:
> Hmm. How much control do you have on the input format? If it's not too late, > rather than swimming against the current maybe you should alter the input so > it can be easily parsed by a POSIX shell I have a lot of control, but I'm not sure what this would look like. I could make the format say that the final line must contain just ".", and is ignored. An EXIT trap could ensure that this final line is always output. But now scripts which need to process each line separately have to ignore it, ie. instead of: while read; do ... done they need: while read; do if [ "$REPLY" = . ]; then continue fi ... done Some extra context is that some of the programs with this input/output protocol are in other languages (usually when the processing involves using some external library in that language), and they would also have to handle this extra complexity in the protocol. I could instead force some special way of representing a blank line, eg. "<blank>", but then code which processes each word separately will need to be more complex than the current: for word in $line; do ... done unless the "special blank line" is "one or more spaces/tabs". But even then, care needs to be taken to ensure that a space gets output instead of a pure blank line. It was around this point that I figured, maybe instead of fixing everything to work around the shell quirk, I could just fix the shell quirk. :) Kev