On Wed, 01 Apr 2026 17:21:15 +0200,
Renaud Allard <[email protected]> wrote:
> 
> Index: usr.bin/patch/patch.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/patch/patch.c,v
> retrieving revision 1.78
> diff -u -p -r1.78 patch.c
> --- usr.bin/patch/patch.c     23 Feb 2026 16:40:45 -0000      1.78
> +++ usr.bin/patch/patch.c
> @@ -292,7 +292,14 @@ main(int argc, char *argv[])
> 
>               /* for ed script just up and do it and exit */
>               if (diff_type == ED_DIFF) {
> -                     do_ed_script();
> +                     if (!skip_rest_of_patch)
> +                             do_ed_script();
> +                     if (ofp)
> +                             fclose(ofp);
> +                     ofp = NULL;
> +                     if (rejfp)
> +                             fclose(rejfp);
> +                     rejfp = NULL;
>                       continue;
>               }
> 

at least this hunk changes how patch works. Here an example:

x $ ls -1a                                                    
.
..
x $ patch -t -i /tmp/example.diff                             
Hmm...  Looks like an ed script to me...
No file to patch.  Skipping...
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: foo.txt
|===================================================================
|--- /dev/null
|+++ foo.txt
--------------------------
(Creating file foo.txt...)
Patching file foo.txt using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
done
x $ ls -1a                                                    
.
..
foo.txt
foo.txt.orig
x $

and I used following example.diff:

0a
line from skipped ed script
.
Index: foo.txt
===================================================================
--- /dev/null
+++ foo.txt
@@ -0,0 +1 @@
+bla-bla



-- 
wbr, Kirill

Reply via email to