argc in s6 vs daemontools

From: Lorenzo <lory.fulgi_at_infinito.it>
Date: Tue, 17 Mar 2015 21:14:07 +0100

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
_at_@ -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
_at_@ -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
_at_@ -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
_at_@ -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
_at_@ -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
Received on Tue Mar 17 2015 - 20:14:07 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC