In order to make a build system in Felix we first need some sane tools for first order operations on files (copying, etc). I consider Unix tools arcane and unprincipled, and of course they don't work on Windows.
I would appreciate help designing the toolset. Here's what I have (almost) now: flx_ls dir pattern flx_rm dir pattern [--test] flx_cp src-dir src-pattern dst-spec [--test] The first command looks in directory dir for all regular files whose names relative to dir match Perl regexp pattern and deletes them. If --test is specified it just prints what it will do without doing it. This operation will not delete directories or other special files, including symlinks. Directories . and .. are ignored. In principle the model I'm using is that directories "do not exist". For example x .* matches x/a.c x/d/a.c x [^/]* match x/a.c but not x/d/a.c x \.flx match x/a.flx x/d/b.flx but not x/a.c This matching mechanism is much saner than shell willcards and recursion switches, and a lot more powerful. The principal drawback is that Perl regexps use characters that the shell interprets so some quoting is required ;( The command flx_cp is a sane file copy. It searches the same way flx_rm does but uses the destination pattern as a target, with \1 \2 etc being replaced by match groups from the src-pattern. [$ may have been a saner choice .. :] This command guarantees not to clobber any of the files: no copies on top of a source file are allow, nor may two files be copied to the same target. The target file can exist, however, and will be overwritten. Time stamps etc are not preserved (the file is copied by ordinary C function calls so the copy is just a new file each time). If the target file specifies a file in a directory the directory is created automatically. Thus, you can do this: flx_cp felix '(.*\.flx)' 'backup/\' and the whole tree of *.flx files located in directory felix will be copied into directory backup. NOTE: at present, flx_cp and "flx flx_cp" do not work the same. This is due to a bug in flx in that it calls the shell to execute external commands, using C function "system()". This means test is parsed by the shell TWICE once going into flx and once call in system, and so quoting is messed up. I plan to fix this by using either posix_spawn or a horrible home-brew fork()/exec() function, to ensure words parsed by the shell are not parsed again (but preserved as words). Unfortunately the command line parsing done by flx uses string concatenation and will have to be changed to use word lists. Anyhow: apart from flx_rm and flx_cp we clearly need flx_mv, again with the guarantee to preserve all data. We also need a way to prune empty directories, say flx_rmdir. So .. the *basic* idea is to get rid of the notion of directories as such, and instead just consider a set of regular files with structured names, and use regexps to work with those names. A few other tools like "rsynch d1 d2" make sense. And one I'd really like: global search and replace over a set of files! Anyhow, the question is: what is a minimal fully functional set of file management tools? Note that most of these tools will be be library functions plus wrappers so that it is possible to manipulate the file system easily inside a program. -- john skaller skal...@users.sourceforge.net ------------------------------------------------------------------------------ RSA® Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language