Kamil, You are right about the semantic of the negative paths. It cuts the partial path from the beginning or end of the other path.
All, Thanks for lots of response to the proposal. Most of the comments are focused on canonicalization of the path (file name). It is just one of the operation I wanted from this command. I don't much care how the canonicalization should be implemented. If there is a standard library function that does this I am happy to use it. What I am proposing here is a generic path manipulation command and the canonicalization is one of the included features. The path command I am proposing does following operations in addition to canonicalization of each path name. It uses familiar algebraic notation to describe the operations. So please provide comments on the usefulness (or not so useful) of having such a command. -Tak 1. Concatenation with a binary operator +. <path0> + <path1> This concatenates two paths. It takes care of this in graceful manner so that missing or double / at the junction is reasonably taken care. Of course the concatenated path is canonicalized. 2. Negative path to eliminate the part of the path. <path0> - <path1> This removes the <path1> from the end of <path0>. - <path0> + <path1> This removes the <path0> from the beginning of <path1> 3. Form a list of path with binary operator ' '. <path0> <path1> This form a list of two paths. 4. Distribute concatenation and elimination operation onto a list of paths with a binary operator *. <path0> * ( <path1> <path2> ) is equivalent to <path0> + <path1> <path0> + <path2> ( <path0> <path1> ) * - <path2> is equivalent to <path0> - <path2> <path1> - <path2> -Tak Fri, 24 Jul 2009 09:08:55 +0200: Kamil Dudka <[email protected]> wrote: > Hello Tak, > > On Friday 24 of July 2009 00:17:07 Tak Ota wrote: > > As a part of file name manipulation commands, in addition to the > > current three commands (basename, dirname, pathchk) could you consider > > introduction of a generic path name manipulation command? See > > attached example. > > did you considered use of canonicalize_file_name() from gnulib (also > available > in glibc)? It can manage many of operations implemented in your code. The > function operates on ordinary C strings. The most frequently operation in > your example is concatenation which is AFAIK trivial operation in all shells. > So maybe we can do most of this by combining shell string concatenation and > canonicalization. > > I am not sure what is the semantic of "negative paths". Should it cut > prefix/postfix of the path? Or am I missing something? > > > The need of this type of command can be satisfied by combination of > > other commands such as sed and awk but it is quite cumbersome as the > > operation is frequently required in writhing Makefiles and shell > > scripts in software development. > > Actually I don't know if we have some utility equivalent to > canonicalize_file_name() function in coreutils now. If not I think it could > be helpful to implement such utility. > > Kamil > _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
