[Toybox] cp --help mangled.

Rob Landley rob at landley.net
Sun Jan 10 21:00:44 PST 2016


On 01/09/2016 02:51 PM, enh wrote:
> the "--preserve" help is split in two, with all the other options
> appearing between (marked here by *** which doesn't actually appear in
> the help output):

Sigh. Yeah, I need to do another pass on scripts/config2help.c.

I implemented the first pass of that file in python many moons ago, but
rewrote it in C so python wouldn't be a build dependency for toybox.
(And this was before python decided to commit seppuku with its 3.x
branch, the problem was .)

Doing extensive string manipulation in C isn't really a _happy_ choice
for me, but it works and is portable.

(No, not perl. Never perl.)

> $ adb shell cp --help
> usage: cp [--preserve=motcxa] [-adlnrsv] [-fipRHLP] SOURCE... DEST
> 
> Copy files from SOURCE to DEST.  If more than one SOURCE, DEST must
> be a directory.
> 
> --preserve takes either a comma separated list of attributes, or the first
> ***
> -F delete any existing destination file first (--remove-destination)
> -H Follow symlinks listed on command line
> -L Follow all symlinks
> -P Do not follow symlinks [default]
> -R recurse into subdirectories (DEST must be a directory)
> -a same as -dpr
> -d don't dereference symlinks
> -f delete destination files we can't write to
> -i interactive, prompt before overwriting existing DEST
> -l hard link instead of copy
> -n no clobber (don't overwrite DEST)
> -p preserve timestamps, ownership, and mode
> -r synonym for -R
> -s symlink instead of copy
> -v verbose
> ***
> letter(s) of:

It's seeing a paragraph starting with - and treating lines at the front
starting with - as options, stripping them out, collating the option
block, and sorting it (with - sorting to the beginning).

Should a paragraph that starts with one or more - lines but doesn't have
a blank line after it count as an option block? I need to work out what
the rules are, and that basically involves looking at all the help text
blocks to find edge cases and write them up...

In theory the easy fix is to rephrase "The --preserve option" so the
paragraph doesn't start with a -. In practice the resulting collated
line doesn't have a blank line before it, and adding an extra blank line
between the usage: line and the --preserve line doesn't help because
extras get eaten in parsing...

As I said, need to change config2help.c...

Rob



More information about the Toybox mailing list