Subject: Re: bug#5926: feature request: mv -p to create missing target dir

From: Bob Proulx <[email-masked]>
Date: Thu, 15 Apr 2010 17:13:41 -0600

Rodolfo Borges wrote:
> $ mv foo ~/some/path/
> mv: cannot create regular file `/home/bart9h/some/path/': Is a directory

No target directory exists.

> $ mkdir -p ~/some/path/
> $ mv foo ~/some/path/

That seems like the best way to do it.

> $ :(
> bash: syntax error near unexpected token `newline'
> ...
> $ :)
> bash: syntax error near unexpected token `)'

Using this format to tell us what you are thinking is very confusing!

> $ mv -vp foo ~/some/path/
> mv: created directory `/home/bart9h/some'
> mv: created directory `/home/bart9h/some/path/'
> `foo' -> `/home/bart9h/some/path/foo'

I don't think this is a good idea.  It could be added.  But does it
really gain you anything over calling mkdir -p?  I don't think so.  It
would simply add code bloat to the program.

Plus it wouldn't be portable.  Other implementations wouldn't have it.
It is only of marginal benefit if at all and so other implementations
might never have it.  In any case you would need to wait years before
the feature trickled down to where you could use it reliably.  Also
you can always accomplish this yourself with a shell script.  In
general things that can be easily encapsulated in a shell script are
not good additions to the utilities.

Adding that option is counter to The Unix Philosophy.  Small is
beautiful.  Make each program do one thing well.  Choose portability
over efficiency.  Use shell scripts to increase leverage and
portability.

Bob