coreutils
[Top][All Lists]
Advanced

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

Re: mkdir new parameter


From: Eric Blake
Subject: Re: mkdir new parameter
Date: Fri, 29 Jul 2011 05:27:21 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11

On 07/28/2011 06:52 PM, Willian Sodré da Paixão wrote:
Almost every time I make a directory, I get into it.
So, I thought: would be nice if a parameter -something create and enter the
new directory.

Thanks for the idea, but we _can't_ implement it in coreutils. The notion of the current working directory is per-process - if you spawn a new mkdir child process, then there is no way that the child can cause the parent to chdir().

Rather, _you_ must implement this as a shell function or alias in your shell. Something like this (untested) would call mkdir with all arguments, and if that succeeds, then change directory to the last argument:

mkdir_cd () {
  mkdir "$@" && eval cd "\"\${$#}\""
}

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



reply via email to

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