I am writing a file copy command (will be really cool :) tools/flx_cp src '(.*)\.flx' 'backup/\1.bak'
Copy lib/stl/stl_list.flx -> backup/lib/stl/stl_list.bak Copy lib/stl/stl_map.flx -> backup/lib/stl/stl_map.bak Copy lib/stl/stl_multimap.flx -> backup/lib/stl/stl_multimap.bak .... It's not actually doing the copies yet. This command will register all the sources and destinations and fail if there's any overlap. In version 2 there'll be a switch so that you can copy a file onto one of the sources, this will do proper parallel copy by copying all such files to temporaries first, then to the target (so the copy is order independent). What confused me was this: flx --test=build/release tools/flx_cp src "\(.*\)\[.\]flx" "backup/\\\\1.bak" OMG! Why all those quotes?? The answer is very unfortunate (will need to be fixed!!!!). It's because Felix uses the system() command to call up the generated binary. So the arguments get parsed by the shell and passed to "flx" which then glues them back together and passes them to the shell again via system(). I will have to change that to use execxxx() function ;( [Frown because probably won't work on Windoze] The copy checks will be done using a Judy1 and JudySL array. JudySL maps the src to dst file. Judy1 records all the dst files. The for each dst, we check it isn't a src (target overlaps src). Also when recording dsts in Judy1 we check it isn't already there (duplicate targets). flx_cp is a *well principled* command, unlike the stupid Unix cp command. The semantics are: flx_cp srcdir srcpat dstpat The srcdir says where to look for files. The search is always recursive and only includes regular files (never directories, symbolic links, . or .. or any other crud). The srcpat is a Perl expression matched against the source files by name *excluding* the srcdir part. It must match the whole name. The dst pat is the target filename with \1 \2 .. etc replace by the extracted subgroups. Destination directories are auto-created. I have done flx_ls. I will do flx_mv and flx_rm. I am also thinking about a Trash bin and undo (not so easy). Then, the REAL program, the one I ACTUALLY want: edit srcdir "srcpat" "dstpat" srchrase dstphrase ... This is a copy, possibly an overwrite, in which we search for srcphrase in the file and replace it with dstphrase. in other words, replace "fred" with "joe" in a set of files, aka identifier renaming. I'll do a "grep" thing first. Eventually these tools will be integrated with Felix syntax, so it can be used a bit like a shell (and Erick will scream for a REPL .. :) -- john skaller skal...@users.sourceforge.net ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language