Re: argc in s6 vs daemontools

2015-03-19 Thread Paul Jarc
Laurent Bercot ska-skaw...@skarnet.org wrote:
  There *may* come a time when I add the handling for N arguments
 to some s6 commands (s6-svc comes to mind), which is another
 reason why I don't want to treat too many arguments as an error
 for now.

I'm in favor of adding that handling, but until that happens I'd say
an error message is appropriate.  The command isn't actually doing
what the user probably intends, and it would be helpful to let them
know that.  It's all the more helpful if the behavior for that
invocation is likely to change in the future.


paul


argc in s6 vs daemontools

2015-03-17 Thread Lorenzo

Hi everyone,

there's a few commands that take N arguments in daemontools and only one 
in s6 - which is a perfectly fine choice, except that most of them 
(think svstat *) will reject no arguments and accept N arguments, but 
only using the 1st one.


These commands are:
- svc
- supervise,svok,svscan? (do the same in the original, so ok)
- svstat
- svscanctl (not in the original)

Here's a boring patch that rejects unused arguments (except for svscan).

---
 src/supervision/s6-supervise.c | 2 +-
 src/supervision/s6-svc.c   | 2 +-
 src/supervision/s6-svok.c  | 2 +-
 src/supervision/s6-svscanctl.c | 2 +-
 src/supervision/s6-svstat.c| 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c
index 4aaf371..02cdd21 100644
--- a/src/supervision/s6-supervise.c
+++ b/src/supervision/s6-supervise.c
@@ -430,7 +430,7 @@ int main (int argc, char const *const *argv)
 {
   iopause_fd x[2] = { { -1, IOPAUSE_READ, 0 }, { -1, IOPAUSE_READ, 0 } } ;
   PROG = s6-supervise ;
-  if (argc  2) strerr_dieusage(100, USAGE) ;
+  if (argc != 2) strerr_dieusage(100, USAGE) ;
   if (chdir(argv[1])  0) strerr_diefu2sys(111, chdir to , argv[1]) ;
   {
 register unsigned int proglen = str_len(PROG) ;
diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c
index e9396de..1433f79 100644
--- a/src/supervision/s6-svc.c
+++ b/src/supervision/s6-svc.c
@@ -57,7 +57,7 @@ int main (int argc, char const *const *argv, char 
const *const *envp)

 }
 argc -= l.ind ; argv += l.ind ;
   }
-  if (!argc) dieusage() ;
+  if (argc != 1) dieusage() ;
   if (updown[1])
   {
 char const *newargv[11] ;
diff --git a/src/supervision/s6-svok.c b/src/supervision/s6-svok.c
index 4a615e9..7fbe061 100644
--- a/src/supervision/s6-svok.c
+++ b/src/supervision/s6-svok.c
@@ -11,7 +11,7 @@
 int main (int argc, char const *const *argv)
 {
   PROG = s6-svok ;
-  if (argc  2) strerr_dieusage(100, USAGE) ;
+  if (argc != 2) strerr_dieusage(100, USAGE) ;
   argv++ ; argc-- ;
   {
 int fd ;
diff --git a/src/supervision/s6-svscanctl.c b/src/supervision/s6-svscanctl.c
index 6529e9c..13cee5e 100644
--- a/src/supervision/s6-svscanctl.c
+++ b/src/supervision/s6-svscanctl.c
@@ -50,7 +50,7 @@ int main (int argc, char const *const *argv)
 }
 argc -= l.ind ; argv += l.ind ;
   }
-  if (!argc) dieusage() ;
+  if (argc != 1) dieusage() ;

   {
 unsigned int arglen = str_len(*argv) ;
diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c
index de8fe0d..b67a2fe 100644
--- a/src/supervision/s6-svstat.c
+++ b/src/supervision/s6-svstat.c
@@ -40,7 +40,7 @@ int main (int argc, char const *const *argv)
 }
 argc -= l.ind ; argv += l.ind ;
   }
-  if (!argc) dieusage() ;
+  if (argc != 1) dieusage() ;

   if (!s6_svstatus_read(*argv, status))
 strerr_diefu2sys(111, read status for , *argv) ;
--
2.1.4