Re: long / short options (was Re: start-stop-daemon does not recognise --start)

2007-10-18 Thread Denys Vlasenko
On Thursday 18 October 2007 18:41, Ralf Friedl wrote:
> Denys Vlasenko wrote:
> > Try this patch.
> > ...
> Do you think it would be useful to define something like this:
> 
> #define OPTION_HELP_TEXT(SHORT, LONG, TEXT) SHORT 
> USE_FEATURE_LONG_OPTIONS(LONG) TEXT
> 
> Then the options could be written as
> 
> OPTION_HELP_TEXT(" -v", ", --verbose", " Verbose\n")
> 
> and the middle Part could be included/excluded as necessary. That would 
> avoid duplicating the description for the "long option" / "no long 
> option" cases and make it easier to maintain.

Unfortunately, this will mess up alignment of text
explaining what each option does, as it depends on exact count
of bytes in options. Otherwise alignment by tabs often breaks.
--
vda
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


long / short options (was Re: start-stop-daemon does not recognise --start)

2007-10-18 Thread Ralf Friedl
Denys Vlasenko wrote:
> Try this patch.
> ...
Do you think it would be useful to define something like this:

#define OPTION_HELP_TEXT(SHORT, LONG, TEXT) SHORT 
USE_FEATURE_LONG_OPTIONS(LONG) TEXT

Then the options could be written as

OPTION_HELP_TEXT(" -v", ", --verbose", " Verbose\n")

and the middle Part could be included/excluded as necessary. That would 
avoid duplicating the description for the "long option" / "no long 
option" cases and make it easier to maintain.

Regards
Ralf Friedl
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: start-stop-daemon does not recognise --start

2007-10-18 Thread Denys Vlasenko
On Thursday 18 October 2007 11:04, Hamish Moffatt wrote:
> On Thu, Oct 18, 2007 at 10:59:50AM +0100, Denys Vlasenko wrote:
> > On Thursday 18 October 2007 01:56, Hamish Moffatt wrote:
> > > On Thu, Oct 18, 2007 at 09:58:41AM +1000, Hamish Moffatt wrote:
> > > > start-stop-daemon claims to offer --start, but then doesn't accept it:
> > > 
> > > Actually all the long options seems to be broken.
> > 
> > Works for me:
> > 
> [..]
> > You probably deselected long options support. Can you post
> > your .config?
> 
> Yes, you're right.
> 
> > Help text needs to be fixed to not show longopts if they are disabled...
> 
> Again, you're right. :) That's why I didn't realise the configuration
> item wasn't set.

Try this patch.
--
vda
diff -d -urpN busybox.5/include/usage.h busybox.6/include/usage.h
--- busybox.5/include/usage.h	2007-10-16 22:50:49.0 +0100
+++ busybox.6/include/usage.h	2007-10-18 11:35:52.0 +0100
@@ -210,21 +210,37 @@
"	-v	Set the file's version/generation number"
 
 #define chcon_trivial_usage \
-   "[OPTIONS] CONTEXT FILE...\n" \
-   "	chcon [OPTIONS] [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...\n" \
-   "	chcon [OPTIONS] --reference=RFILE FILE...\n"
+   "[OPTIONS] CONTEXT FILE..." \
+   "\n	chcon [OPTIONS] [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE..." \
+	USE_FEATURE_CHCON_LONG_OPTIONS( \
+   "\n	chcon [OPTIONS] --reference=RFILE FILE..." \
+	)
 #define chcon_full_usage \
"Change the security context of each FILE to CONTEXT\n" \
-   "\n	-v, --verbose		Verbose" \
-   "\n	-c, --changes		Report changes made" \
-   "\n	-h, --no-dereference	Affect symlinks instead of their targets" \
-   "\n	-f, --silent, --quiet	Suppress most error messages" \
+	USE_FEATURE_CHCON_LONG_OPTIONS( \
+   "\n	-v,--verbose		Verbose" \
+   "\n	-c,--changes		Report changes made" \
+   "\n	-h,--no-dereference	Affect symlinks instead of their targets" \
+   "\n	-f,--silent,--quiet	Suppress most error messages" \
"\n	--reference=RFILE	Use RFILE's group instead of using a CONTEXT value" \
-   "\n	-u, --user=USER		Set user USER in the target security context" \
-   "\n	-r, --role=ROLE		Set role ROLE in the target security context" \
-   "\n	-t, --type=TYPE		Set type TYPE in the target security context" \
-   "\n	-l, --range=RANGE	Set range RANGE in the target security context" \
-   "\n	-R, --recursive		Recurse subdirectories" \
+   "\n	-u,--user=USER		Set user USER in the target security context" \
+   "\n	-r,--role=ROLE		Set role ROLE in the target security context" \
+   "\n	-t,--type=TYPE		Set type TYPE in the target security context" \
+   "\n	-l,--range=RANGE	Set range RANGE in the target security context" \
+   "\n	-R,--recursive		Recurse subdirectories" \
+	) \
+	SKIP_FEATURE_CHCON_LONG_OPTIONS( \
+   "\n	-v	Verbose" \
+   "\n	-c	Report changes made" \
+   "\n	-h	Affect symlinks instead of their targets" \
+   "\n	-f	Suppress most error messages" \
+   "\n	-u USER	Set user USER in the target security context" \
+   "\n	-r ROLE	Set role ROLE in the target security context" \
+   "\n	-t TYPE	Set type TYPE in the target security context" \
+   "\n	-l RNG	Set range RNE in the target security context" \
+   "\n	-R	Recurse subdirectories" \
+	)
+
 
 #define chmod_trivial_usage \
"[-R"USE_DESKTOP("cvf")"] MODE[,MODE]... FILE..."
@@ -780,9 +796,16 @@
 #define dumpleases_full_usage \
"Display DHCP leases granted by udhcpd" \
"\n\nOptions:\n" \
-   "	-f, --file=FILENAME	Leases file to load\n" \
-   "	-r, --remaining		Interpret lease times as time remaining\n" \
-   "	-a, --absolute		Interpret lease times as expire time"
+	USE_GETOPT_LONG( \
+   "	-f,--file=FILE	Leases file to load\n" \
+   "	-r,--remaining	Interpret lease times as time remaining\n" \
+   "	-a,--absolute	Interpret lease times as expire time" \
+	) \
+	SKIP_GETOPT_LONG( \
+   "	-f FILE	Leases file to load\n" \
+   "	-r	Interpret lease times as time remaining\n" \
+   "	-a	Interpret lease times as expire time" \
+	)
 
 #define e2fsck_trivial_usage \
"[-panyrcdfvstDFSV] [-b superblock] [-B blocksize] " \
@@ -1079,21 +1102,38 @@
 #define ftpget_full_usage \
"Retrieve a remote file via FTP" \
"\n\nOptions:\n" \
-   "	-c, --continue	Continue a previous transfer\n" \
-   "	-v, --verbose	Verbose\n" \
-   "	-u, --username	Username to be used\n" \
-   "	-p, --password	Password to be used\n" \
-   "	-P, --port	Port number to be used"
+	USE_GETOPT_LONG( \
+   "	-c,--continue	Continue previous transfer\n" \
+   "	-v,--verbose	Verbose\n" \
+   "	-u,--username	Username\n" \
+   "	-p,--password	Password\n" \
+   "	-P,--port	Port number" \
+	) \
+	SKIP_GETOPT_LONG( \
+   "	-c	Continue previous transfer\n" \
+   "	-v	Verbose\n" \
+   "	-u	Username\n" \
+   "	-p	Password\n

Re: start-stop-daemon does not recognise --start

2007-10-18 Thread Hamish Moffatt
On Thu, Oct 18, 2007 at 10:59:50AM +0100, Denys Vlasenko wrote:
> On Thursday 18 October 2007 01:56, Hamish Moffatt wrote:
> > On Thu, Oct 18, 2007 at 09:58:41AM +1000, Hamish Moffatt wrote:
> > > start-stop-daemon claims to offer --start, but then doesn't accept it:
> > 
> > Actually all the long options seems to be broken.
> 
> Works for me:
> 
[..]
> You probably deselected long options support. Can you post
> your .config?

Yes, you're right.

> Help text needs to be fixed to not show longopts if they are disabled...

Again, you're right. :) That's why I didn't realise the configuration
item wasn't set. 

I ran into this playing with buildroot for the first time. The init
script provided with the dropbear package uses the long options.
Probably it should use the short options, for compatibility.


Thanks

Hamish
-- 
Hamish Moffatt VK3SB <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: start-stop-daemon does not recognise --start

2007-10-18 Thread Denys Vlasenko
On Thursday 18 October 2007 01:56, Hamish Moffatt wrote:
> On Thu, Oct 18, 2007 at 09:58:41AM +1000, Hamish Moffatt wrote:
> > start-stop-daemon claims to offer --start, but then doesn't accept it:
> 
> Actually all the long options seems to be broken.

Works for me:

$ ./busybox start-stop-daemon --start --exec busybox
BusyBox v1.8.0.svn (2007-10-17 19:32:08 IST) multi-call binary
Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.
Licensed under GPLv2. See source distribution for full notice.

Usage: busybox [function] [arguments]...
   or: [function] [arguments]...

BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable.  Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!

Currently defined functions:
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ...

$ ./busybox start-stop-daemon --start --exec ./busybox echo TEST
TEST

You probably deselected long options support. Can you post
your .config?

Help text needs to be fixed to not show longopts if they are disabled...
--
vda
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: start-stop-daemon does not recognise --start

2007-10-17 Thread Hamish Moffatt
On Thu, Oct 18, 2007 at 09:58:41AM +1000, Hamish Moffatt wrote:
> start-stop-daemon claims to offer --start, but then doesn't accept it:

Actually all the long options seems to be broken.


Hamish
-- 
Hamish Moffatt VK3SB <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


start-stop-daemon does not recognise --start

2007-10-17 Thread Hamish Moffatt
start-stop-daemon claims to offer --start, but then doesn't accept it:

start-stop-daemon: unrecognized option `--start'
BusyBox v1.7.2 (2007-10-17 15:06:10 EST) multi-call binary

Usage: start-stop-daemon [OPTIONS] [--start|--stop] ... [-- arguments...]

Start and stop services

Options:
-S|--start  Start
-K|--stop   Stop
-a|--startas pathname   Starts process specified by path
Force process into background
-u|--user username|uid  Stop this user's processes
-x|--exec executableProgram to either start or check
-m|--make-pidfile   Create the -p file and enter pid in it
-n|--name process-name  Stop processes with this name
-p|--pidfile pid-file   Save or load pid using a pid-file
-q|--quiet  Quiet
-o|--oknodo Exit status 0 if nothing done
-v|--verboseVerbose
-N|--nicelevel NAdd N to process's nice level
-s|--signal signal  Signal to send (default TERM)
-c|--chuid user[:[group]]   Change to specified user/group


Hamish
-- 
Hamish Moffatt VK3SB <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox