coreutils
[Top][All Lists]
Advanced

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

Re: New utility suggestion: chdir(1)


From: Colin Watson
Subject: Re: New utility suggestion: chdir(1)
Date: Sun, 27 Aug 2017 08:23:40 +0100
User-agent: NeoMutt/20170113 (1.7.2)

On Sat, Aug 26, 2017 at 04:00:11PM -0700, Pádraig Brady wrote:
> If we were to provide this I think chdir is a fine name.
> It's a pity we have to have this heavy weight chaining of execs like this
> to set each process attribute. This is more general though, than adding
> --chdir to other "context" type programs like chroot etc.
> Note GNU chroot has a --skip-chdir which nearly does what you want.
> I.E. you could os.chdir("/chroot/build") before calling "chroot --skip-dir 
> ...",
> however that's currently restricted for greater protection to when
> you're not actually changing the root directory.  I suppose we could relax
> the check to verify that getcwd() was _below_ the specified chroot path.
> Of course none of this helps with jexec, lxc etc.

Indeed; I really want something composable rather than playing
whack-a-mole with every possible wrapper command.

> Another option to consider is to add --chdir to env(1) since they
> would often be used together and could be done more efficiently with a single 
> exec?

That's a good idea, and I agree they're often used together.  I'd
already slipped and implemented chdir(1), but I think that suggestion
may be better: it results in a much shorter patch, and it avoids the
problem with some shells (e.g. zsh) implementing their own "chdir"
built-ins with different semantics.

I've attached both patches; my preference following Pádraig's suggestion
is the second one ("env: add --chdir option"), but I'd be happy either
way.

If either of these requires a copyright assignment and I don't have one
on file for coreutils, then I'd appreciate it if a maintainer could get
the ball rolling on the necessary paperwork.

Thanks,

-- 
Colin Watson                                       [address@hidden]

Attachment: 0001-chdir-new-command-to-run-command-with-changed-CWD.patch
Description: Text Data

Attachment: 0001-env-add-chdir-option.patch
Description: Text Data


reply via email to

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