bug-coreutils
[Top][All Lists]
Advanced

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

Re: A request for addition of a command


From: Kamil Dudka
Subject: Re: A request for addition of a command
Date: Fri, 24 Jul 2009 21:17:26 +0200
User-agent: KMail/1.9.7

On Friday 24 of July 2009 20:37:02 Tak Ota wrote:
> 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

Just a few notes in-line.

> 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.

We can do the same with:

$ readlink -f "$path0/$path1"

> 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>

The algebra seems really strange to me. Has the '-' operator usual semantic
of unary '-' (meaning inverse element with regards to binary operation '+')? 
Then should the following be always true:
    1. -(-a) == a
    2. a - b == a + (-b)

Do we have any real life use-case for the operator '-'? I think concatenation 
with "/.." and/or sed invocation are mostly sufficient.

> 3. Form a list of path with binary operator ' '.
>
>    <path0> <path1>
>
> This form a list of two paths.

$ printf "%s %s\n" `readlink -fn $path1` `readlink -fn $path2`

> 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>

We can do this by running the above mentioned in a loop (using shell).

Kamil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]