Working on a question for codegolf.se, trying to do a simple text replacement.
- Given a file
coin.txtcontaining 1 word, either
- I have an
s/heads/1/n\ s/tails/-1/n\ wq .
- Then I execute it from the terminal (macos, zsh), as follows: (per "Ed Mastery", chapter 111)
[~/golf/ed]λ ed coin.txt < flip.ed; cat coin.txt 6 ? tails
Expected the script to change
-1. I get the same problem from BSD and GNU ed (
/usr/local/bin/ged, and TIO.run for that matter). Neither one seems able to execute multiple replacements.
Here's an example on TIO.run, I think it's running GNU ed.
Is there a problem in my
ed script? Or is it a bug in the mighty
g/heads/s//1/ g/tails/s//-1/ wq .