"gksudo -u <anything other than root>" always returns error code 1
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| gksu (Ubuntu) |
Undecided
|
Unassigned |
Bug Description
Binary package hint: gksu
This is normal:
$ gksudo -u root echo $HOME
/home/foobar
$ echo $?
0
But why does this return error code 1?
$ gksudo -u foobar echo $HOME
/home/foobar
$ echo $?
1
I'm running all commands as user foobar, which is a sudoer.
Interestingly, no error is reported by sudo in the same situation
$ sudo -u foobar echo $HOME
/home/foobar
$ echo $?
0
Using GKsu version 2.0.2 on Karmic.
WeatherGod (ben-v-root) wrote : | #1 |
Victor Engmark (victor-engmark) wrote : | #2 |
Thanks for the tip, but it doesn't seem like "--" works (at least the way I understand it):
$ gksudo -u foobar -- echo $HOME
/home/foobar
$ echo $?
1
Tuomas Heino (iheino+ub) wrote : | #3 |
Tested with Maverick, symptoms are still the same.
And it indeed looks like a duplicate of LP: #51633
Victor Engmark (victor-engmark) wrote : | #4 |
@Tuomas: This is not a duplicate of #51633 - That bug deals with the fact that gksu does *not* return the exit code of the command.
Victor Engmark (victor-engmark) wrote : | #5 |
Still an issue in GKsu version 2.0.2. This makes it unnecessarily tricky to create reliable shell programs (set -o errexit).
I suspect that this might be a duplicate of a very old bug: #51633
That being said, there are also other webpages saying that the gksu programs are not parsing the command line properly and that you should use '--' to convert a sudo command into a gksudo command.