On 2013-09-16 Mon 23:28 PM |, Alexander Hall wrote: > > sed can do it all. Really.
This is getting beyond me Alexander..... Is sed a mechanism to step away from using file(1) ? > 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" > > Moreover, > > - you probably want to unset $interpreter when done. > - we might want to re_quote the entire $pexp later instead. >