"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got: rm * removes current directory
To:
Omar Polo <op@omarpolo.com>
Cc:
Mikhail <mp39590@gmail.com>, gameoftrees@openbsd.org
Date:
Mon, 29 May 2023 11:48:50 +0200

Download raw body.

Thread
On Mon, May 29, 2023 at 10:51:47AM +0200, Omar Polo wrote:
> I won't feel bad if your diff gets committed, and the only real
> comment I have on that is in the getcwd() usage in lib: I think it
> would be better if code in lib/ doesn't change behaviour based on $PWD
> (for foture-proofness.)

The library works with absolute paths internally to avoid problems with
relative paths and $PWD. But inspite of this, code running an operation
within a work tree should not be changing its current working directory
until the operation is done.
Our command line client calls getcwd() near the beginning of each
operation and never calls chdir().

And what would be the alternative to directly calling getcwd()?
Require callers to pass $PWD into lib/ code? That wouldn't really change
anything, would it? We could do this but is the parameter churn worth it?