Re: PATCH: relpath (original) (raw)


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


From: Jim Meyering
Subject: Re: PATCH: relpath
Date: Mon, 02 Jan 2012 12:55:36 +0100

Pádraig Brady wrote:

On 12/31/2011 11:27 AM, Jim Meyering wrote: > Pádraig Brady wrote: > ... >>> Reading only the documentation for --relative-base=FILE, >>> I am not sure how it works: >>> >>> --relative-base=FILE'_ _>>> Ensure both the --relative-to' and processed files are >>> subdirectories of FILE, or otherwise output the absolute file name. >>> Note this option honors the -m' and -e' options pertaining to >>> file existence. >>> >>> An example or two would help a lot. >> >> I'll add something along these lines: > > Thanks. > >> $ realpath --relative-to=/usr /tmp /usr/bin >> ../tmp > > I see two lines of output. I guess you missed the latter? > > $ ./realpath --relative-to=/usr /tmp /usr/bin > ../tmp > bin > >> $ realpath --relative-base=/usr --relative-to=/usr /tmp /usr/bin >> /tmp >> bin > > Good. That makes it clearer. > The "Ensure" threw me. It's not really ensuring it. > Maybe something like this? > > --relative-base=BASE'_ _> When both the --relative-to' file and a listed FILE are > descendants of BASE, print a BASE-relative name for FILE. > Otherwise, print FILE's absolute name. > Note this option honors the -m' and -e' options pertaining to > file existence. > > There's probably more to consider when the --relative-to= and > --relative-base= specified names are different, but I haven't > thought about that.

Well it's setting a BASE, past which "../" will not be generated for. This does seem fairly useful and provides compatibility with relpath -d .... I went with:

--relative-base=BASE'_ _Only output relative names when both the --relative-to' and processed FILEs are descendants of BASE. Otherwise output the absolute file name. Note this option honors the @option{-m} and @option{-e} options pertaining to file existence.

Thanks.

But that doesn't say what a printed relative name is relative to. Think of it as a specification. I could not use that description as a basis for implementing the code. As a naive user, I'd be hard pressed to predict what it will print.

Formatting nit: It's not clear if what you've quoted is texinfo, but it looks like it. If so, you'll want @option{...} around --relative-to and to use @var{file} and @var{base} so that we get FILE and BASE in "info" output.

If you retain the first two words, please reorder them: "Output only"

I will push the df change tomorrow and then make a pre-release snapshot, planning to make the release late in the week or early next.