Synopsis: patch(1) with a hyphen argument doesn't read from standard input
Category: userland
Environment:
System : OpenBSD 5.1
Details : OpenBSD 5.1-current (GENERIC.MP) #230: Mon Apr 2
12:44:39 MDT 2012
[email protected]:/usr/src/sys/arch/i386/compile/GENERIC.MP
Architecture: OpenBSD.i386
Machine : i386
Description:
According to patch(1) manpage, if patchfile is omitted or is a
hyphen it should read from standard input, instead it errs out with a
message "can't find -".
How-To-Repeat:
cat somediff | patch -
Fix:
patch starts processing it's arguments in filearg from index 1
instead of 0 in main...
for (open_patch_file(filearg[1]); there_is_another_patch();
reinitialize_almost_everything()) {
Let arguments be filled from filearg[1] instead of 0.
Index: patch.c
===================================================================
RCS file: /cvs/src/usr.bin/patch/patch.c,v
retrieving revision 1.49
diff -u -p -r1.49 patch.c
--- patch.c 24 Jul 2010 01:10:12 -0000 1.49
+++ patch.c 1 Apr 2012 06:59:16 -0000
@@ -589,7 +589,7 @@ get_some_switches(void)
Argv += optind;
if (Argc > 0) {
- filearg[0] = savestr(*Argv++);
+ filearg[1] = savestr(*Argv++);
Argc--;
while (Argc > 0) {
if (++filec == MAXFILEC)