The su(1) writes:
The options are as follows:
Use the settings of the specified login class. The login class
must be defined in login.conf(5). Only allowed for the super-
But in the examples:
su -m operator -c poweroff
Starts a shell as user operator, and runs the command poweroff.
So the "-c" doesn't specify the login class instead with it can run a command as an another user.
Not a bug. In the example you quote, the -c is not an option to su but an arg to the invoked shell. The third example should make this clear.
I've made this mistake reading the man page too. I wonder how we could improve the wording to make it more clear or perhaps change the syntax? It is confusing.
(In reply to Steve Wills from comment #2)
Since you can run any command as an arg to (the shell invoked by) su, it's unfortunately impossible to make the sets of options disjoint. Consider eg the contrived:
su -c staff fred -c "ls -c"
which has three option spaces.
(In reply to Bob Bishop from comment #1)
Indeed. And the description of example describes it too (but I didn't read it).
As Steve wrote it's confusing. Maybe one sentence in the "-c class" section in manpage would be clear.
Sorry for unnecessary report.
*** This bug has been marked as a duplicate of bug 6859 ***
The examples in the man page try to make the distinction clear:
> In this example, -c is passed to the shell of the user "operator", and is not interpreted as an argument to su.
> (Most shells expect the argument to -c to be a single word).
> Note: in this example, the first -c option applies to su while the second is an argument to the shell being invoked.
I'll accept that there's clearly still an opportunity for confusion here (as demonstrated by the existence of this PR). That said, the issue is described in each of the three examples that have a `-c` argument and I'm not quite sure how to make this more clear. I'm happy to update the man page if we can come up with good suggestions.
I was inattentive when didn't read (the perfect) explanation in examples.
Maybe only one sentence in "-c":
Note it's possible to run a command inside invoked shell usually with shell(!) option "-c". See more in EXAMPLES section.
(Sorry for incorrect english - I hope it's clear)
(In reply to Ed Maste from comment #7)
I'm sitting on a patch for the su(1) manual to improve the description a bit. I'll post it soon when I polish it a bit.
Reopen as 0mp is working on a patch.
I've posted a draft to phabricator so that the patch does not get lost on my disk.