Command line arguments are not positionally independent

Issue #51 resolved
Sergey Maslyakov created an issue

When testing the syntax of a custom control file, "monit" errors out if the "-t" option goes before the "-c" option with a file name:

$ ./monit/bin/monit-linux-x86 -t -c ./monit/conf/monitrc 
Cannot find the control file at ~/.monitrc, /etc/monitrc, /uadev/attprod/smaslyak/monit/linux-x86/monit/etc/monitrc, /usr/local/etc/monitrc or at ./monitrc 

If I reverse the order of the arguments, it works fine:

$ ./monit/bin/monit-linux-x86 -c ./monit/conf/monitrc -t
Generated unique Monit id e10354d234a32101c1be335e47aeab29 and stored to '/home/smaslyak/tmp/monit-poc/monit/var/.monit.id'
Control file syntax OK

Comments (5)

  1. Tildeslash repo owner

    Confirmed. When -t -r or -i are used, handle_options runs do_init at once without considering later arguments such as -c control-file. The code is much simplified by doing it like this, but usability suffer and we agree that arguments should be position independent. It is a drag to change the code, but actions when given the above arguments need to be deferred to make sure any control file given are read first and used.

  2. Log in to comment