Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemctl: be nice to users and give hint about "-.mount" #11065

Merged
merged 2 commits into from
Dec 7, 2018

Conversation

keszybz
Copy link
Member

@keszybz keszybz commented Dec 6, 2018

If people like this, something like this can be added to the other commands that take a unit name.

(Please use 'rebase & merge', commits in this PR are unrelated.)

https://bugzilla.redhat.com/show_bug.cgi?id=1656639
Using "--" is a trick that is hard to discover. Let's give users a hint:

$ build/systemctl status -.service
  build/systemctl: invalid option -- '.'
  Hint: to specify units starting with a dash, use "--":
        build/systemctl [OPTIONS...] {COMMAND} -- -.service ...

I use program_invocation_name because that's what getopt seems to use.
"::" is used in the option string so that getopt doesn't complain about
a missing argument in case somebody passes "-." as the argument. After all
"." is not a real option.
@yuwata
Copy link
Member

yuwata commented Dec 7, 2018

Lgtm.

@yuwata yuwata merged commit 2e7e19c into systemd:master Dec 7, 2018
/* Output an error mimicking getopt, and print a hint afterwards */
log_error("%s: invalid option -- '.'", program_invocation_name);
log_notice("Hint: to specify units starting with a dash, use \"--\":\n"
" %s [OPTIONS...] {COMMAND} -- -.%s ...",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add "Example:" to this line to clarify that this is an example?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually a bit more than an example, because it uses optarg to construct a part of the correct commandline. Alos, there's an ellipsis at the end, so I think it's pretty clear that this is not the full thing.

@keszybz keszybz deleted the systemctl-help-hint branch December 7, 2018 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants