[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

es decompression hack



[despite my warning note that immediately preceeded this note,
i couldn't wait to share this hack which i just coded up with
the list.]

here's one simple hook function overriding that you might find
useful.  put this in your .esrc (provided you're using 0.8 or
later, though one could construct an 0.79 version with test
instead of access) and you'll be able to use < with files that
don't exist, provided that a compressed .Z version of the files
does exist.

let (open = $fn-%open) {
	fn %open fd file cmd {
		let (opened-file = $&false) {
			catch @ e {
				if {!$opened-file && !access $file && access -r $file.Z} {
					%pipe {zcat $file} 1 $fd $cmd
				} {
					throw $e
				}
			} {
				$open $fd $file {
					opened-file = $&true
					$cmd
				}
			}
		}
	}
}

i haven't tested this extensively, but it handles the obvious
cases and i like that it's so easy.

paul