On Mon, Sep 16, 2013 at 11:28:06PM +0200, Alexander Hall wrote: > sed can do it all. Really. Notes: > > - I separate re_quote() cause I think it can be useful in other places. > - I think re_quote() is (basic) regex complete. > - I don't care if the interpreter is (or seems) nonexistant, as that > shouldn't be a runtime error. > - I'm sure sed may die horribly if you try to feed it a 9GB oneline > file. However, if so, it should not produce any output anyway. ;) > If this would ever be considered a real problem, dd(1) would help > (as espie already mentioned). > > re_quote() { sed 's/\([]^$*.\\[]\)/\\\1/g'; } > > interpreter=$( > sed -n 's/^#![[:space:]]*\(.*\)/\1 /p;q' "${daemon}" | > re_quote) > pexp="$interpreter$pexp"
Ah, but what happens when you run that thru a pure binary file that spans a single line ?...