3 ms·
I suppose you're correct about the terminating newline case, in that the newline is only added once. I'm not sure what you'd call it, but I'm talking about it
by robertelder 11y ago
I suppose you're correct about the terminating newline case, in that the newline is only added once. I'm not sure what you'd call it, but I'm talking about it as if it were a kind of idempotent 'base case'. For example:
If you do
echo -en "" | ( (vim - -esbnN -c 'w!/dev/stderr|q!' >/dev/null) 2>&1) | xxd
versus
echo -en "" | ( (vim - -esbnN -c 'w!/dev/stderr|q!' >/dev/null) 2>&1) | ( (vim - -esbnN -c 'w!/dev/stderr|q!' >/dev/null) 2>&1) | xxd
These will the same output, so it is idempotent. However, if you build upon that and do
echo -en "" | ( (vim - -esbnN -c '%!xxd' -c 'w!/dev/stderr|q!' >/dev/null) 2>&1) | xxd
versus
echo -en "" | ( (vim - -esbnN -c '%!xxd' -c 'w!/dev/stderr|q!' >/dev/null) 2>&1) | ( (vim - -esbnN -c '%!xxd' -c 'w!/dev/stderr|q!' >/dev/null) 2>&1) | xxd
The result is not the same, and therefore not idempotent if you plan to add extra -c commands.