Description
Ed is strange. At least the ed in macOS 10.12. Following the procedure outlined in the README, I observed ed print ?
and then exit with exit status 2. Aparently something went wrong, but what? After some experimentation it looks as though ed would receive its commands faster than it could handle them. Which is strange, as it should be able to simply not perform any input while it's still busy. Nevertheless, providing the script at stdin would fail while typing the commands one at a time worked. In the end I ran the script as follows:
sed 's/#.*//' move_drop_indexes.ed | grep -v '^$' | while read -r i; do
sleep 1
echo "$i" 1>&2
echo "$i"
done | ed databasename.psql
This leaves one second delay between subsequent commands. It also strips comments, but that by itself was not enough to make this work for me. It prints the commands to standard error, so that in case of an error one can see which command failed.
Do you want to add any of this to the command line? Or move this over to Python instead of ed?