[Toybox] recent cp checkins

Rob Landley rob at landley.net
Sun Jan 13 04:08:42 PST 2013


On 01/12/2013 06:44:16 AM, milto57 at attglobal.net wrote:
> Hi Rob.
> 
> New account, let the spam begin (NOT) :-)
> 
> When you added the help for cp  -n I noticed the
> help for -p is missing,

$ ./toybox help cp | grep '[-]p'
-p  preserve timestamps, ownership, and permissions

?

> even though the help -a
> refers to it.  Now I notice a few others are also
> undocumented.

There's a longstanding missing feature in the help text, which is that  
multiple config options don't get collated properly. In this case,  
there's a CONFIG_CP and CONFIG_CP_MORE (all the non-posix options,  
-rdavsl).

The problem is that I need to merge "usage:" lines, which involves a  
certain amount of string parsing that's tricky to do in shell. I should  
take another stab at it...

> Also, this looks suspicious:
> http://landley.net/hg/toybox/rev/5bc258a4c750
> 
>     1.22 +    // Detect recursive copies via
> repeated top node (cp -R .. .) or
>     1.23 +    // identical source/target (fun with
> hardlinks).
>     1.24 +    if ((TT.top.st_dev == try->st.st_dev
> && TT.top.st_ino == try->st.st_ino
>     1.25 +         && (catch = TT.destname))
>     1.26 +        || (!fstatat(cfd, catch, &cst,
> 0) && cst.st_dev == try->st.st_dev
>     1.27 +         && cst.st_ino == try->st.st_ino))
> 
> Because the first if that assigns catch is highly
> conditional and the second half uses it
> unconditionally.

It's initialized in the declaration:

   char *catch = try->parent ? try->name : TT.destname

The assignment in the first half of that just changes the value,  
otherwise we stick with the default. (In reality, the assignment is  
just to get the right error_ms, we trust it never to be null because  
it's initialized in the caller.)

Rob
 1358078922.0


More information about the Toybox mailing list