[Toybox] feature request: toybox cp --parents

Rob Landley rob at landley.net
Mon Jul 24 13:23:47 PDT 2017

On 07/24/2017 11:09 AM, Alexander Reiche wrote:
> Dear Rob,
> first of all thank you for your hard work, and just ignore this email if
> you are busy :)
> in my shell script, it was necessary using toybox instead of busybox,
> because i need to copy selinux labels.
> now in toybox, the "*cp --parents*" option is missing. please may you
> tell me the right way for a feature request?

The man page is not helping, what does this feature _do_...


Ok. Yeah, looks reasonably straightforward to implement. When
implementing mkdir -p I factored out mkpathat() into lib/ and we've
already got the path reclaim logic for cp -s.

(Aside: I'm proud that my cp -rs plumbing works better than ubuntu's, I
don't have a "can make relative symbolic links only in current
directory" error, I made "cp -rs ../blah blah" _work_ with the
appropriate number of ../.. at each level. :)

Sigh. The problem with --parent is the UI. I dislike --longopts with no
corresponding short option (not unix and the help text looks terrible),
but I _also_ try to avoid incompatibilities with ubuntu's version so
even if I haven't implemented a shortopt I don't want to reuse that
letter because then people would have to pick sides writing scripts. Grrr...

Hmmm... ok, so this is mv -p but cp -p and -P are both deployed. I could
make it be cp -F (copy full path) maybe? And then have the
as a compatibility option...

No, I already used -F as the shortopt for --remove-destination. Hmmm. -D
for copy leading directories? But -D implies it should copy empty
directories too. What does --parent actually do? Let's try:

  $ mkdir banana
  $ cp --parent banana banana2
  cp: with --parents, the destination must be a directory

Ok, first the longopt is --parents but it's accepting --parent (I am not
doing that fix, your scripts), secondly it's objecting that the
_destination_ has to be a directory when the whole point is this creates
missing directories, and third:

  $ mkdir banana2
  $ cp --parent banana banana2
  cp: omitting directory ‘banana’

Oh this extension has GNU written all over it. In crayon. And the N is

Right, lemme take a stab at doing this right. -D should act like -r in
terms of "what we're copying" (the blog entry I linked to above gave me
the impression it already _was_ just from what uses they considered
obvious). If we're mkdir-ing the destination then we should do so for
the top level one too just for conceptual consistency.

Sanity check: does this screw up your use case?


More information about the Toybox mailing list