If you add --verbose to the ed command, you'll find that it's complaining about an unsaved buffer. Try adding an " echo 'Q' " command after the " echo 'p ...' ".
For reference, as of v1.14.1, an EOF on stdin behaves like 'q'. That's likely the source of the behavior change. On Tue, Oct 3, 2023 at 9:02 AM Danie Theron - DSV <danie.the...@dsv.com> wrote: > Good day Antonio and other maintainers of ed, > > We are using a software version control system which our developers are > using to make changes to programs and deploy to different environments. > The back end of the application is using Unix/Linux commands to manipulate > & reconstructing programs. The main commands are "diff" and "ed". > For example when a program is created on the system, it stores the full > content of v1.0 in the database. > > When changes are made to the initial version of the v1.0 program, only the > delta changes (generated from the "diff" command) v1.1, v1.2, v1.3 and so > forth is stored in the database so that the database does not grow > excessively by storing the full contents of the modified program versions. > > When the program is continually modified or gets deployed to an > environment, it uses "ed" to reconstruct the specific version of the > program, the deltas are applied to the v1.0 program. > > This is working fine up to v1.13 of "ed", but since v1.14 up to the latest > version v1.19, the deltas are not being applied correctly causing > corruption in the reconstruction of programs. > > (We have migrated from Solaris 11.4 using an ancient version of "ed" - > version unknown, to RHEL 8 which uses "ed" version 1.14.2, which corrupted > a lot of our programs. As an interim solution I have compiled v1.13 of > "ed", and updated the system scripts to use "ed" v1.13) > > Can you please find the cause and release a bugfix version that solves > this issue? > > Please see my test cases below & attached: > > # cat textfile_v1.0.txt > AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA > BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB > CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC > DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD > EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE > FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF > GGGGGGGGGGGGGGGGGGGGGGGGGGGG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DDDDDDDDDDDDDDDDDDDDDDD > EEEEEEEEEEEEEEEEEEEEEEZEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE > FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF > SGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG > > # diff -e textfile_v1.0.txt textfile_v1.1.txt > textfile_v1.1_delta.txt > > # cat textfile_v1.1_delta.txt > 5c > EEEEEEEEEEEEEEEEEEEEEEZEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE > . > 1c > AAAAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA > . > > # diff -e textfile_v1.1.txt textfile_v1.2.txt > textfile_v1.2_delta.txt > > # cat textfile_v1.2_delta.txt > 7c > SGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG > . > 3a > > . > > # diff -e textfile_v1.2.txt textfile_v1.3.txt > textfile_v1.3_delta.txt > > # cat textfile_v1.3_delta.txt > 7c > FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF > . > 2c > BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBHBBBBBBBB > . > > ############################################################## > # ---> ed version 1.13 <---- # > # Reconstruct v1.3 of the file using version 1.0 of the file # > # and applying the v1.1, v1.2 & v1.3 delta files # > ############################################################## > > # /home/userabc/ed/ed-1.13/ed -V > GNU ed 1.13 > Copyright (C) 1994 Andrew L. Moore. > Copyright (C) 2016 Antonio Diaz Diaz. > License GPLv3+: GNU GPL version 3 or later < > http://gnu.org/licenses/gpl.html> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. > > # (cat textfile_v1.1_delta.txt ; echo '1,$p') | > /home/userabc/ed/ed-1.13/ed - textfile_v1.0.txt > > textfile_v1.1_reconstructed.txt > # (cat textfile_v1.2_delta.txt ; echo '1,$p') | > /home/userabc/ed/ed-1.13/ed - textfile_v1.1_reconstructed.txt > > textfile_v1.2_reconstructed.txt > # (cat textfile_v1.3_delta.txt ; echo '1,$p') | > /home/userabc/ed/ed-1.13/ed - textfile_v1.2_reconstructed.txt > > textfile_v1.3_reconstructed.txt > # > # diff textfile_v1.3.txt textfile_v1.3_reconstructed.txt > # > >>>>> GREAT - successfully reconstructed v1.3 using the full v1.0 and > applying the v1.1, v1.2 & v1.3 deltas > > > ############################################################## > # ---> ed version 1.14 <---- # > # Reconstruct v1.3 of the file using version 1.0 of the file # > # and applying the v1.1, v1.2 & v1.3 delta files # > ############################################################## > > # /home/userabc/ed/ed-1.14/ed -V > GNU ed 1.14 > Copyright (C) 1994 Andrew L. Moore. > Copyright (C) 2017 Antonio Diaz Diaz. > License GPLv3+: GNU GPL version 3 or later < > http://gnu.org/licenses/gpl.html> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. > > # (cat textfile_v1.1_delta.txt ; echo '1,$p') | > /home/userabc/ed/ed-1.14/ed - textfile_v1.0.txt > > textfile_v1.1_reconstructed.txt > # diff textfile_v1.1.txt textfile_v1.1_reconstructed.txt > 7a8 > > ? > # (cat textfile_v1.2_delta.txt ; echo '1,$p') | > /home/userabc/ed/ed-1.14/ed - textfile_v1.1_reconstructed.txt > > textfile_v1.2_reconstructed.txt > # diff textfile_v1.2.txt textfile_v1.2_reconstructed.txt > 8a9,10 > > ? > > ? > # (cat textfile_v1.3_delta.txt ; echo '1,$p') | > /home/userabc/ed/ed-1.14/ed - textfile_v1.2_reconstructed.txt > > textfile_v1.3_reconstructed.txt > # diff textfile_v1.3.txt textfile_v1.3_reconstructed.txt > 8a9,11 > > ? > > ? > > ? > > >>>>> NOT GOOD - ed v1.14 corrupts the reconstructions using the full v1.0 > and applying the v1.1, v1.2 & v1.3 deltas > > > ############################################################## > # ---> ed version 1.19 <---- # > # Reconstruct v1.3 of the file using version 1.0 of the file # > # and applying the v1.1, v1.2 & v1.3 delta files # > ############################################################## > > # /home/userabc/ed/ed-1.19/ed -V > GNU ed 1.19 > Copyright (C) 1994 Andrew L. Moore. > Copyright (C) 2023 Antonio Diaz Diaz. > License GPLv2+: GNU GPL version 2 or later < > http://gnu.org/licenses/gpl.html> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. > # > # (cat textfile_v1.1_delta.txt ; echo '1,$p') | > /home/userabc/ed/ed-1.19/ed - textfile_v1.0.txt > > textfile_v1.1_reconstructed.txt > # diff textfile_v1.1.txt textfile_v1.1_reconstructed.txt > 7a8 > > ? > # (cat textfile_v1.2_delta.txt ; echo '1,$p') | > /home/userabc/ed/ed-1.19/ed - textfile_v1.1_reconstructed.txt > > textfile_v1.2_reconstructed.txt > # diff textfile_v1.2.txt textfile_v1.2_reconstructed.txt > 8a9,10 > > ? > > ? > # (cat textfile_v1.3_delta.txt ; echo '1,$p') | > /home/userabc/ed/ed-1.19/ed - textfile_v1.2_reconstructed.txt > > textfile_v1.3_reconstructed.txt > # diff textfile_v1.3.txt textfile_v1.3_reconstructed.txt > 8a9,11 > > ? > > ? > > ? > > >>>>> ALSO NOT GOOD - latest ed v1.19 still corrupts the reconstructions > using the full v1.0 and applying the v1.1, v1.2 & v1.3 deltas > > > Thank you so much, any help would be much appreciated. > > > Danie Theron > >