TYPE ts = SYM -> inf ; inf = ANY; filet = SYM | tab | sgml ; ;--------------------------------------------------------------------- tab = rs: STR /* register separator */ fs: STR ; /* field separator */ ENDTYPE unixrun(com)=let(a = popen(com,"r"), b = readf(a), = pclose(a)) in b; file2sexp(com,ty)= let(com= com ++ " | any2sexp " ++ if( ty=='sl -> "", is-tab(ty) -> "-sc -F -R " ++ fs(ty) ++ " " ++ rs(ty), else -> ""), a = popen(com,"r"), b = readf(a), = pclose(a)) in b; unix(f,arg) = (t[f])(arg); t<-['ls -> lambda(x). unixrun("ls -1 " ++ x ++ " | any2sexp"), 'lsla -> lambda(x). let(a=unixrun("ls -la "++x++" | any2sexp -sc")) in [y[8] -> y | y <- a ] ]; ;-------------------------------------------------------------------- ; ls(x)=unixrun("ls -1 "++x++" | any2sexp"); ls2(x)= file2sexp("ls -1 "++x, 'sl); grep(x,y)= file2sexp("grep \""++x++"\" "++y, 'sl); ;--------------------------------------------------------------------- ; teste ; "line to be grepped" _ok("any2sexp", if ( "unix.cam" in elems(unix('ls, "*.cam")) /\ "unix.cam" in elems(ls("*.cam")) /\ "unix.cam" in elems(ls2("*.cam")) /\ length(grep("line to be grepped","unix.cam")) == 2 /\ ; "unix.cam" in dom(unix('lsla, "*.cam")) /\ true -> 1, else -> 0),1) ; =comm func getas(o) pre subset(dom(o),{'rs,'fs,'type,'com}) returns let(comm= o['com] ++ " | any2sexp ", comm = comm ++ if( o['type]=='tab )then " -sc" else "" , comm = comm ++ if( subset({'rs,'fs},dom(o) ) -> "-F -R '" ++ o['rs] ++ "' '" ++o['rs]++"'" , 'rs in dom(o) -> "-R '" ++ o['rs] ++ "'", 'fs in dom(o) -> "-F '" ++ o['fs] ++ "'", else -> ""), = princ(comm), a = popen(comm,"r"), b = readf(a), = pclose(a)) in b; pp(getas(['com -> "date +'%m %d %H %M %S'", 'type -> 'txt, 'rs -> " "])); =cut