On Sun, Jan 10, 2016 at 9:00 PM, Rob Landley <r...@landley.net> wrote:
> 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...

yeah, and adding an actual "--preserve" line after rephrasing the
existing one does give us the missing blank line, but still sorts
--preserve ahead of the other options, which seems weird.

still, even without the blank line, rephrasing does makes us less
unreadable and look slightly less broken, and if the right fix isn't
going to happen any time soon...


This still isn't right (because there's a missing blank line), but
it's less unreadable than splitting the --preserve documentation
and inserting all the other options in the middle.
---
 toys/posix/cp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index f932ca4..e698d45 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -56,8 +56,8 @@ config CP_PRESERVE
   help
     usage: cp [--preserve=motcxa]

-    --preserve takes either a comma separated list of attributes, or the first
-    letter(s) of:
+    The --preserve option takes either a comma separated list of attributes,
+    or the first letter(s) of:

             mode - permissions (ignore umask for rwx, copy suid and sticky bit)
        ownership - user and group
-- 
2.6.0.rc2.230.g3dd15c0


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



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
From 9718d5f40213bf14c6ecf8ea504e1c2ecc72a932 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Mon, 11 Jan 2016 10:19:11 -0800
Subject: [PATCH] Work around config2help.c's cp --preserve confusion.

This still isn't right (because there's a missing blank line), but
it's less unreadable than splitting the --preserve documentation
and inserting all the other options in the middle.
---
 toys/posix/cp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index f932ca4..e698d45 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -56,8 +56,8 @@ config CP_PRESERVE
   help
     usage: cp [--preserve=motcxa]
 
-    --preserve takes either a comma separated list of attributes, or the first
-    letter(s) of:
+    The --preserve option takes either a comma separated list of attributes,
+    or the first letter(s) of:
 
             mode - permissions (ignore umask for rwx, copy suid and sticky bit)
        ownership - user and group
-- 
2.6.0.rc2.230.g3dd15c0

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to