Separate lstat filesize checking assertion into a seperate function.
Separate the regex shell escape find and replace, and quote wrapping logic,
into a separate function.