Why doesn't GNU `su` respect end of options?Any options to replace GNU coreutils on Linux?GNU/Hurd vs....

Are runways booked by airlines to land their planes?

Gravitational Force Between Numbers

Testing using real data of the customer

Visual Block Mode edit with sequential number

Does water in vacuum form a solid shell or freeze solid?

Papers on ArXiv as main references

Why did OJ Simpson's trial take 9 months?

Why did Drogon spare this character?

Question about Shemot, locusts

What is the function of は in the context?

Where is Jon going?

Unary Enumeration

Is superuser the same as root?

Can a UK national work as a paid shop assistant in the USA?

Is a world with one country feeding everyone possible?

How to deceive the MC

Why is 'additive' EQ more difficult to use than 'subtractive'?

Are there any German nonsense poems (Jabberwocky)?

How to remove new line added by readarray when using a delimiter?

To exponential digit growth and beyond!

Piping the output of comand columns

How does Dreadhorde Arcanist interact with split cards?

Are there guidelines for finding good names for LaTeX 2e packages and control sequences defined in these packages?

Why this character is punished instead of being honoured?



Why doesn't GNU `su` respect end of options?


Any options to replace GNU coreutils on Linux?GNU/Hurd vs. GNU/LinuxHow to source correct startup scripts on interactive, non-login shellWhen and how was the double-dash (--) introduced as an end of options delimiter in Unix/Linux?Why didn't GNU Info succeed man?Why does GNU say it is “Not Unix”?su silently fails with bash in /etc/passwdWhy is ddrescue slow when it could be faster on error free areas?Want to preserve bashrc and vimrc when switching to non-root usersGNU datamash transpose example doesn't seem to work correctly






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







-1















When I run



user@hostname:~$ su -- root -z


I get



bash: -z: invalid option
Usage: bash [GNU long option] [option] ...
...


The above is the behavior I expect.



When I run



user@hostname:~$ su -l -- root -z


I get



-su: -z: invalid option
Usage: -su [GNU long option] [option] ...
...


I use the invalid option -z only to demonstrate which command is parsing the option.



This behavior irks me to no end. su continued searching for options after I declared end of options. Am I missing something, is this a bug or just horrible design?










share|improve this question




















  • 1





    I am confused.... Which OS has a -z switch for sudo or su? It looks like you might be trying to do either su - root or sudo -i. It's never sudo su. The commands are mutually exclusive.

    – Christopher
    57 mins ago











  • -z is not an option for su or bash. It is intentional. I used a fake option to demonstrate which command was parsing the fake option I gave it.

    – Harold Fischer
    56 mins ago













  • Was sudo su supposed to demonstrate something in particular? Ref @Christopher's question

    – Seamus
    43 mins ago











  • @Seamus No I was using sudo for debugging so I wouldn't have to enter a password for root every time I tested it. I tested without sudo and the behavior is the same. I can see how it completely diluted the question and made it confusing

    – Harold Fischer
    42 mins ago




















-1















When I run



user@hostname:~$ su -- root -z


I get



bash: -z: invalid option
Usage: bash [GNU long option] [option] ...
...


The above is the behavior I expect.



When I run



user@hostname:~$ su -l -- root -z


I get



-su: -z: invalid option
Usage: -su [GNU long option] [option] ...
...


I use the invalid option -z only to demonstrate which command is parsing the option.



This behavior irks me to no end. su continued searching for options after I declared end of options. Am I missing something, is this a bug or just horrible design?










share|improve this question




















  • 1





    I am confused.... Which OS has a -z switch for sudo or su? It looks like you might be trying to do either su - root or sudo -i. It's never sudo su. The commands are mutually exclusive.

    – Christopher
    57 mins ago











  • -z is not an option for su or bash. It is intentional. I used a fake option to demonstrate which command was parsing the fake option I gave it.

    – Harold Fischer
    56 mins ago













  • Was sudo su supposed to demonstrate something in particular? Ref @Christopher's question

    – Seamus
    43 mins ago











  • @Seamus No I was using sudo for debugging so I wouldn't have to enter a password for root every time I tested it. I tested without sudo and the behavior is the same. I can see how it completely diluted the question and made it confusing

    – Harold Fischer
    42 mins ago
















-1












-1








-1








When I run



user@hostname:~$ su -- root -z


I get



bash: -z: invalid option
Usage: bash [GNU long option] [option] ...
...


The above is the behavior I expect.



When I run



user@hostname:~$ su -l -- root -z


I get



-su: -z: invalid option
Usage: -su [GNU long option] [option] ...
...


I use the invalid option -z only to demonstrate which command is parsing the option.



This behavior irks me to no end. su continued searching for options after I declared end of options. Am I missing something, is this a bug or just horrible design?










share|improve this question
















When I run



user@hostname:~$ su -- root -z


I get



bash: -z: invalid option
Usage: bash [GNU long option] [option] ...
...


The above is the behavior I expect.



When I run



user@hostname:~$ su -l -- root -z


I get



-su: -z: invalid option
Usage: -su [GNU long option] [option] ...
...


I use the invalid option -z only to demonstrate which command is parsing the option.



This behavior irks me to no end. su continued searching for options after I declared end of options. Am I missing something, is this a bug or just horrible design?







su gnu






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 52 mins ago







Harold Fischer

















asked 1 hour ago









Harold FischerHarold Fischer

688415




688415








  • 1





    I am confused.... Which OS has a -z switch for sudo or su? It looks like you might be trying to do either su - root or sudo -i. It's never sudo su. The commands are mutually exclusive.

    – Christopher
    57 mins ago











  • -z is not an option for su or bash. It is intentional. I used a fake option to demonstrate which command was parsing the fake option I gave it.

    – Harold Fischer
    56 mins ago













  • Was sudo su supposed to demonstrate something in particular? Ref @Christopher's question

    – Seamus
    43 mins ago











  • @Seamus No I was using sudo for debugging so I wouldn't have to enter a password for root every time I tested it. I tested without sudo and the behavior is the same. I can see how it completely diluted the question and made it confusing

    – Harold Fischer
    42 mins ago
















  • 1





    I am confused.... Which OS has a -z switch for sudo or su? It looks like you might be trying to do either su - root or sudo -i. It's never sudo su. The commands are mutually exclusive.

    – Christopher
    57 mins ago











  • -z is not an option for su or bash. It is intentional. I used a fake option to demonstrate which command was parsing the fake option I gave it.

    – Harold Fischer
    56 mins ago













  • Was sudo su supposed to demonstrate something in particular? Ref @Christopher's question

    – Seamus
    43 mins ago











  • @Seamus No I was using sudo for debugging so I wouldn't have to enter a password for root every time I tested it. I tested without sudo and the behavior is the same. I can see how it completely diluted the question and made it confusing

    – Harold Fischer
    42 mins ago










1




1





I am confused.... Which OS has a -z switch for sudo or su? It looks like you might be trying to do either su - root or sudo -i. It's never sudo su. The commands are mutually exclusive.

– Christopher
57 mins ago





I am confused.... Which OS has a -z switch for sudo or su? It looks like you might be trying to do either su - root or sudo -i. It's never sudo su. The commands are mutually exclusive.

– Christopher
57 mins ago













-z is not an option for su or bash. It is intentional. I used a fake option to demonstrate which command was parsing the fake option I gave it.

– Harold Fischer
56 mins ago







-z is not an option for su or bash. It is intentional. I used a fake option to demonstrate which command was parsing the fake option I gave it.

– Harold Fischer
56 mins ago















Was sudo su supposed to demonstrate something in particular? Ref @Christopher's question

– Seamus
43 mins ago





Was sudo su supposed to demonstrate something in particular? Ref @Christopher's question

– Seamus
43 mins ago













@Seamus No I was using sudo for debugging so I wouldn't have to enter a password for root every time I tested it. I tested without sudo and the behavior is the same. I can see how it completely diluted the question and made it confusing

– Harold Fischer
42 mins ago







@Seamus No I was using sudo for debugging so I wouldn't have to enter a password for root every time I tested it. I tested without sudo and the behavior is the same. I can see how it completely diluted the question and made it confusing

– Harold Fischer
42 mins ago












1 Answer
1






active

oldest

votes


















2















-su: -z: invalid option
Usage: -su [GNU long option] [option] ...
...



This is the error output from Bash, not from su. If you'd continued to quote, the very next line mentions a script file, for example, and later on the --rcfile option, which clearly doesn't belong to su. You could also compare to the output of su -z, which will be a different error.



If you run



su -l -- root --version


you'll see that the argument is passed along and it's Bash that reports its version.



Bash is reporting itself as -su (note the -) because that's what is in its zeroth argument when su invokes it as a login shell, not because it is su itself (or even -su).





Note that the su manual does actually state that:




You can use the -- argument to separate su options from the arguments
supplied to the shell.




which is what is happening here: the argument is passed along to the shell. If you'd left the -- out, you'd get the su error output



su: invalid option -- 'z'
Usage: su [options] [LOGIN]
...


instead.






share|improve this answer
























  • Thanks for taking the time to point out my silly mistake. When I run su -- root -, bash complains it cannot set the the terminal process group. Shouldn't bashjust treat the - as end of options and start up the shell like the - isn't there?

    – Harold Fischer
    14 mins ago













  • If you provide shell arguments su doesn't give it a controlling TTY (try su -- root -x). I don't quite understand that choice, but it is consistent with su -c 'bash' so I suppose that's part of it.

    – Michael Homer
    5 mins ago












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f520060%2fwhy-doesnt-gnu-su-respect-end-of-options%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2















-su: -z: invalid option
Usage: -su [GNU long option] [option] ...
...



This is the error output from Bash, not from su. If you'd continued to quote, the very next line mentions a script file, for example, and later on the --rcfile option, which clearly doesn't belong to su. You could also compare to the output of su -z, which will be a different error.



If you run



su -l -- root --version


you'll see that the argument is passed along and it's Bash that reports its version.



Bash is reporting itself as -su (note the -) because that's what is in its zeroth argument when su invokes it as a login shell, not because it is su itself (or even -su).





Note that the su manual does actually state that:




You can use the -- argument to separate su options from the arguments
supplied to the shell.




which is what is happening here: the argument is passed along to the shell. If you'd left the -- out, you'd get the su error output



su: invalid option -- 'z'
Usage: su [options] [LOGIN]
...


instead.






share|improve this answer
























  • Thanks for taking the time to point out my silly mistake. When I run su -- root -, bash complains it cannot set the the terminal process group. Shouldn't bashjust treat the - as end of options and start up the shell like the - isn't there?

    – Harold Fischer
    14 mins ago













  • If you provide shell arguments su doesn't give it a controlling TTY (try su -- root -x). I don't quite understand that choice, but it is consistent with su -c 'bash' so I suppose that's part of it.

    – Michael Homer
    5 mins ago
















2















-su: -z: invalid option
Usage: -su [GNU long option] [option] ...
...



This is the error output from Bash, not from su. If you'd continued to quote, the very next line mentions a script file, for example, and later on the --rcfile option, which clearly doesn't belong to su. You could also compare to the output of su -z, which will be a different error.



If you run



su -l -- root --version


you'll see that the argument is passed along and it's Bash that reports its version.



Bash is reporting itself as -su (note the -) because that's what is in its zeroth argument when su invokes it as a login shell, not because it is su itself (or even -su).





Note that the su manual does actually state that:




You can use the -- argument to separate su options from the arguments
supplied to the shell.




which is what is happening here: the argument is passed along to the shell. If you'd left the -- out, you'd get the su error output



su: invalid option -- 'z'
Usage: su [options] [LOGIN]
...


instead.






share|improve this answer
























  • Thanks for taking the time to point out my silly mistake. When I run su -- root -, bash complains it cannot set the the terminal process group. Shouldn't bashjust treat the - as end of options and start up the shell like the - isn't there?

    – Harold Fischer
    14 mins ago













  • If you provide shell arguments su doesn't give it a controlling TTY (try su -- root -x). I don't quite understand that choice, but it is consistent with su -c 'bash' so I suppose that's part of it.

    – Michael Homer
    5 mins ago














2












2








2








-su: -z: invalid option
Usage: -su [GNU long option] [option] ...
...



This is the error output from Bash, not from su. If you'd continued to quote, the very next line mentions a script file, for example, and later on the --rcfile option, which clearly doesn't belong to su. You could also compare to the output of su -z, which will be a different error.



If you run



su -l -- root --version


you'll see that the argument is passed along and it's Bash that reports its version.



Bash is reporting itself as -su (note the -) because that's what is in its zeroth argument when su invokes it as a login shell, not because it is su itself (or even -su).





Note that the su manual does actually state that:




You can use the -- argument to separate su options from the arguments
supplied to the shell.




which is what is happening here: the argument is passed along to the shell. If you'd left the -- out, you'd get the su error output



su: invalid option -- 'z'
Usage: su [options] [LOGIN]
...


instead.






share|improve this answer














-su: -z: invalid option
Usage: -su [GNU long option] [option] ...
...



This is the error output from Bash, not from su. If you'd continued to quote, the very next line mentions a script file, for example, and later on the --rcfile option, which clearly doesn't belong to su. You could also compare to the output of su -z, which will be a different error.



If you run



su -l -- root --version


you'll see that the argument is passed along and it's Bash that reports its version.



Bash is reporting itself as -su (note the -) because that's what is in its zeroth argument when su invokes it as a login shell, not because it is su itself (or even -su).





Note that the su manual does actually state that:




You can use the -- argument to separate su options from the arguments
supplied to the shell.




which is what is happening here: the argument is passed along to the shell. If you'd left the -- out, you'd get the su error output



su: invalid option -- 'z'
Usage: su [options] [LOGIN]
...


instead.







share|improve this answer












share|improve this answer



share|improve this answer










answered 41 mins ago









Michael HomerMichael Homer

52.5k9144181




52.5k9144181













  • Thanks for taking the time to point out my silly mistake. When I run su -- root -, bash complains it cannot set the the terminal process group. Shouldn't bashjust treat the - as end of options and start up the shell like the - isn't there?

    – Harold Fischer
    14 mins ago













  • If you provide shell arguments su doesn't give it a controlling TTY (try su -- root -x). I don't quite understand that choice, but it is consistent with su -c 'bash' so I suppose that's part of it.

    – Michael Homer
    5 mins ago



















  • Thanks for taking the time to point out my silly mistake. When I run su -- root -, bash complains it cannot set the the terminal process group. Shouldn't bashjust treat the - as end of options and start up the shell like the - isn't there?

    – Harold Fischer
    14 mins ago













  • If you provide shell arguments su doesn't give it a controlling TTY (try su -- root -x). I don't quite understand that choice, but it is consistent with su -c 'bash' so I suppose that's part of it.

    – Michael Homer
    5 mins ago

















Thanks for taking the time to point out my silly mistake. When I run su -- root -, bash complains it cannot set the the terminal process group. Shouldn't bashjust treat the - as end of options and start up the shell like the - isn't there?

– Harold Fischer
14 mins ago







Thanks for taking the time to point out my silly mistake. When I run su -- root -, bash complains it cannot set the the terminal process group. Shouldn't bashjust treat the - as end of options and start up the shell like the - isn't there?

– Harold Fischer
14 mins ago















If you provide shell arguments su doesn't give it a controlling TTY (try su -- root -x). I don't quite understand that choice, but it is consistent with su -c 'bash' so I suppose that's part of it.

– Michael Homer
5 mins ago





If you provide shell arguments su doesn't give it a controlling TTY (try su -- root -x). I don't quite understand that choice, but it is consistent with su -c 'bash' so I suppose that's part of it.

– Michael Homer
5 mins ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f520060%2fwhy-doesnt-gnu-su-respect-end-of-options%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m