Description of problem: Application of a copy-and-pasted patch file fails: $ patch --normal --verbose --input patch mysql_backup.sh Hunk #1 succeeded at 15. Hunk #2 succeeded at 109. patch: **** `>' expected at line 35 of patch "SOB" Okay, the problems seems to be that a link that looks like '>' in the patch file is considered unfriendly. It possibly looked once like '> ' or '>\t', but copy & paste may have mangled it. Workaround is to manually edit the patch file and add spaces or tabs. A quick look at the source of patch-2.5.9 (through Google code search) shows that the error occurs around here, though I have trouble extrating semantics out of this compact C style. The condition (buf[0] != '>' || (buf[1] != ' ' && buf[1] != '\t')) indicates that '> ' is acceptable while '>' is not. It might be useful to relax this apparently fascist attitude to input. for (i++; i<=p_end; i++) { chars_read = get_line (); if (chars_read == (size_t) -1) { p_end = i - 1; return -1; } if (!chars_read) fatal ("unexpected end of file in patch at line %s", format_linenum (numbuf0, p_input_line)); if (buf[0] != '>' || (buf[1] != ' ' && buf[1] != '\t')) fatal ("`>' expected at line %s of patch", format_linenum (numbuf0, p_input_line)); chars_read -= 2 + (i == p_end && incomplete_line ()); p_len[i] = chars_read; if (! (p_line[i] = savebuf (buf + 2, chars_read))) { p_end = i-1; return -1; } p_Char[i] = '+'; }
Don't copy and paste patches. Patch is very cautious by design, and must always alert the user to any discrepancies between the patch input and the files being altered. If you have a patch with word-wrapped lines or other whitespace damage, unwrapdiff from the patchutils package may help you -- but the best advice is to avoid damaging patches and to treat them as binary files.
Ok, makes sense.