coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

nohup interprets subcommand flags as its own flags

Open kevinburke1 opened this issue 5 years ago • 2 comments

If I run, for example, nohup go get -u github.com/kevinburke/rest using the nohup from coreutils, I get this output:

$ ./local/coreutils/bin/nohup go get -u github.com/kevinburke/rest
nohup: error: Unrecognized option: 'u'
nohup 0.0.1

Usage:
  nohup COMMAND [ARG]...
  nohup OPTION

Run COMMAND ignoring hangup signals.
If standard input is terminal, it'll be replaced with /dev/null.
If standard output is terminal, it'll be appended to nohup.out instead,
or $HOME/nohup.out, if nohup.out open failed.
If standard error is terminal, it'll be redirected to stdout.

Options:
    -h, --help          Show help and exit
    -V, --version       Show version and exit

The nohup binary is treating -u as its own command line flag, when it is part of the sub argument.

GNU nohup has no issues running the command above.

kevinburke1 avatar Oct 21 '20 20:10 kevinburke1

OpenBSD nohup does not accept -- before a subcommand, it tries to run a program called --.

GNU nohup accepts -- but also does not try to parse flags in the subcommand as flags in the parent program.

kevinburke1 avatar Oct 21 '20 23:10 kevinburke1

Not sure if this should be a separate issue, but timeout has the same issue.

jaggededgedjustice avatar Feb 20 '21 15:02 jaggededgedjustice

Fixed since https://github.com/uutils/coreutils/pull/1871 because the trailing_var_arg setting of clap is set (also for timeout).

tertsdiepraam avatar Sep 10 '22 19:09 tertsdiepraam