-
Notifications
You must be signed in to change notification settings - Fork 53
patch: fix external ed invocation #904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mknos
commented
Jan 4, 2025
- This version of patch first attempts to process an ed diff by running an external ed command, then falls back to processing the ed commands directly
- I noticed the external ed code was always failing but I didn't debug it until now
- Problem1: SIGCHLD happens normally when ed exits but it was being treated as an error (removing signal handlers fixes it)
- Problem2: write command sent to ed was not terminated by a newline, so ed would never run the command
- Problem3: after writing to o_file, the offset of filehandle $out was at byte 26, so the test line comparison wasn't correct
- With this patch I can process a simple ed diff on Linux without the code reaching PLAN_J
* This version of patch first attempts to process an ed diff by running an external ed command, then falls back to processing the ed commands directly * I noticed the external ed code was always failing but I didn't debug it until now * Problem1: SIGCHLD happens normally when ed exits but it was being treated as an error (removing signal handlers fixes it) * Problem2: write command sent to ed was not terminated by a newline, so ed would never run the command * Problem3: after writing to o_file, the offset of filehandle $out was at byte 26, so the test line comparison wasn't correct * With this patch I can process a simple ed diff on Linux without the code reaching PLAN_J
bin/patch
Outdated
local $SIG{CHLD} = sub { die 'Bad child...' }; | ||
open ED, '|-', qw(ed - -s), $self->{i_file} or die "Couldn't fork ed: $!"; | ||
my $cmd = 'ed -s ' . $self->{'i_file'}; | ||
open ED, '|-', $cmd or die "Couldn't fork ed: $!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a problem with the list form of the pipe? That should be safer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted. I added a commit to convert the ed arguments back to a list and repeated the original test.