Running ps2epsi with certain postscript files generated the following error sed: -e expression #1, char 42: Invalid range end Upon investigation, this seems to be due to [^!-~] in the following sed line sed -e '/^%%BeginPreview:/,/^%%EndPreview[^!-~]*$/d' -e '/^%!PS-Adobe/d'\ -e '/^%%[A-Za-z][A-Za-z]*[^!-~]*$/d' -e '/^%%[A-Za-z][A-Za-z]*: /d' which I think might be a bug The sed man page says, that to include a '-' in a negated list, it has to be the first of the last item in the list --- sed man entry `[LIST]' `[^LIST]' Matches any single character in LIST: for example, `[aeiou]' matches all vowels. A list may include sequences like `CHAR1-CHAR2', which matches any character between (inclusive) CHAR1 and CHAR2. The caret reverses the meaning of the regexp, so that it matches any single character NOT in list. To include `]' in the list, make it the first character (after the caret if needed), to include `-' in the list, make it the first or last; to include `^' put it after the first character.
The sed script is correct as it stands. The regexp [^!-~] matches any characters between ! and ~ inclusive. The '-' in the regexp indicates a range and is NOT intended to match only '!', '-' and '~', but rather the entire range. This bug will be closed unless a PostScript file is attached with a specific command line that exhibts the problem.
The bug is real, but is related to something different. Character ranges are locale dependent, and to make [^!-~] really work as expected you have to add LANG=C at the beginning of the script. GNU sed compiled with older glibc versions aborts on the above regexp if the locale is not C.
*** This bug has been marked as a duplicate of 688703 ***