bug-coreutils
[Top][All Lists]
Advanced

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

Re: A feature request


From: Eric Blake
Subject: Re: A feature request
Date: Tue, 23 Mar 2010 09:42:50 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Lightning/1.0b1 Thunderbird/3.0.3

On 03/23/2010 09:31 AM, Claes Lindvall wrote:
> Very often I create a directory and then I want to move to that directory.
> I would like an option that makes it possible.
> Ex.
> # mkdir -c <dir> (-c changedir)

Thanks for the suggestion.  However, it is impossible to do as a
utility.  The notion of the current directory is a per-process notion,
with child processes inheriting their current working directory from the
parent process at the time of the fork()/exec() sequence.  There is NO
way in Unix for a child process to further influence the parents choice
of current directory, any more than there is for the parent process to
affect the child's current directory beyond its initial setting at the
fork().  Therefore, there is no way we can add a utility to coreutils to
do that.

On the other hand, this is a PERFECT use case for enhancing your
interactive shell.  For example, if you use bash, you can add this to
your ~/.bashrc, and get a mkcdir function that does exactly what you want:

mkcdir () {
  mkdir "$1" && cd "$1"
}

You can even get fancier and add logic to support passing options to mkdir.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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