Hi,

Here is a patch for tar that documents long options without a short option
in --help

Long options documented:
--overwrite
--lzma
--strip-components
--no-recursion
--to-command
--numeric-owner
--no-same-permissions

Minor reformatting is also included for alignment purposes.

Inspired by GNU tar, I am proposing not to exhaustively list all the
supported long options in the usage line, and instead replace them by a
generic [OPTIONS]... placeholder, but open to other suggestions on this.

Thanks,
Chris
commit 2f2ab4fe9cb85fcdaa4beb9a6d9ab83f9eb6ff69
Author: Christophe Vidal <[email protected]>
Date:   Sun Nov 29 22:24:24 2020 +0700

    [tar-usage] updated tar usage

diff --git a/archival/tar.c b/archival/tar.c
index 93184cc2a..ea3a262c5 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -775,7 +775,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
 //usage:	IF_FEATURE_TAR_NOPRESERVE_TIME("m")
 //usage:	"vokO] "
 //usage:	"[-f TARFILE] [-C DIR] "
-//usage:	IF_FEATURE_TAR_FROM("[-T FILE] [-X FILE] "IF_FEATURE_TAR_LONG_OPTIONS("[--exclude PATTERN]... "))
+//usage:	IF_FEATURE_TAR_FROM("[-T FILE] [-X FILE] "IF_FEATURE_TAR_LONG_OPTIONS("[OPTION]... "))
 //usage:	"[FILE]..."
 //usage:#define tar_full_usage "\n\n"
 //usage:	IF_FEATURE_TAR_CREATE("Create, extract, ")
@@ -783,58 +783,65 @@ static llist_t *append_file_list_to_list(llist_t *list)
 //usage:	"or list files from a tar file"
 //usage:     "\n"
 //usage:	IF_FEATURE_TAR_CREATE(
-//usage:     "\n	c	Create"
+//usage:     "\n	c                         Create"
 //usage:	)
-//usage:     "\n	x	Extract"
-//usage:     "\n	t	List"
-//usage:     "\n	-f FILE	Name of TARFILE ('-' for stdin/out)"
-//usage:     "\n	-C DIR	Change to DIR before operation"
-//usage:     "\n	-v	Verbose"
-//usage:     "\n	-O	Extract to stdout"
+//usage:     "\n	x                         Extract"
+//usage:     "\n	t                         List"
+//usage:     "\n	-f FILE                   Name of TARFILE ('-' for stdin/out)"
+//usage:     "\n	-C DIR                    Change to DIR before operation"
+//usage:     "\n	-v                        Verbose"
+//usage:     "\n	-O                        Extract to stdout"
 //usage:	IF_FEATURE_TAR_NOPRESERVE_TIME(
-//usage:     "\n	-m	Don't restore mtime"
+//usage:     "\n	-m                        Don't restore mtime"
 //usage:	)
-//usage:     "\n	-o	Don't restore user:group"
+//usage:     "\n	-o                        Don't restore user:group"
 ///////:-p - accepted but ignored, restores mode (aliases in GNU tar: --preserve-permissions, --same-permissions)
-//usage:     "\n	-k	Don't replace existing files"
+//usage:	IF_FEATURE_TAR_LONG_OPTIONS(
+//usage:     "\n	--overwrite               Replace existing files"
+//usage:	)
+//usage:     "\n	-k                        Don't replace existing files"
 //usage:	IF_FEATURE_SEAMLESS_Z(
-//usage:     "\n	-Z	(De)compress using compress"
+//usage:     "\n	-Z                        (De)compress using compress"
 //usage:	)
 //usage:	IF_FEATURE_SEAMLESS_GZ(
-//usage:     "\n	-z	(De)compress using gzip"
+//usage:     "\n	-z                        (De)compress using gzip"
 //usage:	)
 //usage:	IF_FEATURE_SEAMLESS_XZ(
-//usage:     "\n	-J	(De)compress using xz"
+//usage:     "\n	-J                        (De)compress using xz"
 //usage:	)
 //usage:	IF_FEATURE_SEAMLESS_BZ2(
-//usage:     "\n	-j	(De)compress using bzip2"
+//usage:     "\n	-j                        (De)compress using bzip2"
 //usage:	)
-//usage:     "\n	-a	(De)compress based on extension"
+//usage:	IF_FEATURE_SEAMLESS_LZMA(
+//usage:	IF_FEATURE_TAR_LONG_OPTIONS(
+//usage:     "\n	--lzma                    (De)compress using lzma"
+//usage:	)
+//usage:	)
+//usage:     "\n	-a                        (De)compress based on extension"
 //usage:	IF_FEATURE_TAR_CREATE(
-//usage:     "\n	-h	Follow symlinks"
+//usage:     "\n	-h                        Follow symlinks"
 //usage:	)
 //usage:	IF_FEATURE_TAR_FROM(
-//usage:     "\n	-T FILE	File with names to include"
-//usage:     "\n	-X FILE	File with glob patterns to exclude"
+//usage:     "\n	-T FILE                   File with names to include"
+//usage:     "\n	-X FILE                   File with glob patterns to exclude"
 //usage:	IF_FEATURE_TAR_LONG_OPTIONS(
-//usage:     "\n	--exclude PATTERN	Glob pattern to exclude"
+//usage:     "\n	--exclude PATTERN         Glob pattern to exclude"
 //usage:	)
 //usage:	)
+//usage:	IF_FEATURE_TAR_LONG_OPTIONS(
+//usage:     "\n	--strip-components NUMBER NUMBER of leading components to strip"
+//usage:     "\n	--no-recursion            Don't descend in directories"
+//usage:	IF_FEATURE_TAR_TO_COMMAND(
+//usage:     "\n	--to-command COMMAND      Pipe files to COMMAND"
+//usage:	)
+//usage:     "\n	--numeric-owner           Use numeric user:group"
+//usage:     "\n	--no-same-permissions     Apply umask on permissions"
+//usage:	)
 //usage:
 //usage:#define tar_example_usage
 //usage:       "$ zcat /tmp/tarball.tar.gz | tar -xf -\n"
 //usage:       "$ tar -cf /tmp/tarball.tar /usr/local\n"
 
-// Supported but aren't in --help:
-//	lzma
-//	no-recursion
-//	numeric-owner
-//	no-same-permissions
-//	overwrite
-//IF_FEATURE_TAR_TO_COMMAND(
-//	to-command
-//)
-
 enum {
 	OPTBIT_KEEP_OLD = 8,
 	IF_FEATURE_TAR_CREATE(   OPTBIT_CREATE      ,)
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to