Re: [PATCH] doc-diff: don't `cd_to_toplevel` before calling `usage`

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

 



On Sun, Feb 3, 2019 at 3:37 AM Martin Ågren <martin.agren@xxxxxxxxx> wrote:
> `usage` tries to call $0, which might very well be "./doc-diff", so if
> we `cd_to_toplevel` before calling `usage`, we'll end with an error to
> the effect of "./doc-diff: not found" rather than a friendly `doc-diff
> -h` output. Granted, all of these `usage` calls are in error paths, so
> we're about to exit anyway, but the user experience of something like
> `(cd Documentation && ./doc-diff)` could be a bit better than
> "./doc-diff: not found".
>
> This regressed in ad51743007 ("doc-diff: add --clean mode to remove
> temporary working gunk", 2018-08-31) where we moved the call to
> `cd_to_toplevel` to much earlier. Move it back to where it was, and
> teach the "--clean" code to cd on its own. This way, we only cd once
> we've verified the arguments.

Thanks for spotting this; I wasn't aware of it when crafting ad51743007.

I wonder if a more fruitful, longer-term fix which would save us from
having to worry about this in the future, would be to make
git-sh-setup.sh remember the original $0 before cd_to_toplevel() and
then employ the original value when usage() re-execs with the -h
option. That would also avoid the slightly ugly repeated
cd_to_top_level() and 'tmp' assignment in this patch.

> Signed-off-by: Martin Ågren <martin.agren@xxxxxxxxx>



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux