Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

`daemon --help` only prints help in interactive terminals

Open illwieckz opened this issue 3 years ago • 4 comments

daemon --help only prints help in interactive terminals:

$ ./daemon --help
Unvanquished 0.52.1 Linux x86_64 May 28 2022
cmdline: --help
Usage: daemon [-OPTION]... [-connect <uri> | +COMMAND...]

Possible options are:
  -h, -help                print this help and exit
  -v, -version             print version and exit
  -homepath <path>         set the path used for user-specific configuration files and downloaded dpk files
  -libpath <path>          set the path containing additional executables and libraries
  -pakpath <path>          add another path from which dpk files are loaded
  -resetconfig             reset all cvars and keybindings to their default value
  -curses                  activate the curses interface
  -set <variable> <value>  set the value of a cvar
  -connect unv://<address>[:<port>]>
                           connect to server at startup
  +<command> <args>        execute an ingame command after startup

Order is important, -options must be set before +commands.
Nothing is read and executed after -connect option and the following URI.
If another instance is already running, commands will be forwarded to it.
$ ./daemon --help | cat
Unvanquished 0.52.1 Linux x86_64 May 28 2022
cmdline: --help
$ echo "$(./daemon --help)"
Unvanquished 0.52.1 Linux x86_64 May 28 2022
cmdline: --help
$ unbuffer ./daemon --help | cat
Unvanquished 0.52.1 Linux x86_64 May 28 2022
cmdline: --help
Usage: ./daemon [-OPTION]... [-connect <uri> | +COMMAND...]

Possible options are:
  -h, -help                print this help and exit
  -v, -version             print version and exit
  -homepath <path>         set the path used for user-specific configuration files and downloaded dpk files
  -libpath <path>          set the path containing additional executables and libraries
  -pakpath <path>          add another path from which dpk files are loaded
  -resetconfig             reset all cvars and keybindings to their default value
  -curses                  activate the curses interface
  -set <variable> <value>  set the value of a cvar
  -connect unv://<address>[:<port>]>
                           connect to server at startup
  +<command> <args>        execute an ingame command after startup

Order is important, -options must be set before +commands.
Nothing is read and executed after -connect option and the following URI.
If another instance is already running, commands will be forwarded to it.

illwieckz avatar May 29 '22 17:05 illwieckz

Same with ./daemon -v.

illwieckz avatar May 29 '22 17:05 illwieckz

That's weird because the code relies on basic printf.

Also the code seems to run as other command line options like the -connect action is working.

illwieckz avatar May 29 '22 17:05 illwieckz

It prints things correctly if I replace printf by Log::Notice, even with -curses (it's probably too early to get this printed into the curses console and then wiped out at exiting).

illwieckz avatar May 29 '22 17:05 illwieckz

Also I was afraid that by using Log::Notice the help message gets written in daemon.log but this is indeed too early (because the homepath is not known yest since it's expected to be modifiable there).

illwieckz avatar May 29 '22 17:05 illwieckz