Timeline for How can I detect that no options were passed with getopts?
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 12, 2012 at 5:09 | vote | accept | Hussain Tamboli | ||
| Oct 12, 2012 at 5:09 | vote | accept | Hussain Tamboli | ||
| Oct 12, 2012 at 5:09 | |||||
| Oct 11, 2012 at 10:30 | comment | added | Hussain Tamboli | what if I was running other shell? zsh, sh. does any shell other than bash take care of this condition? | |
| Oct 11, 2012 at 10:27 | history | edited | Stéphane Chazelas | CC BY-SA 3.0 | added 200 characters in body |
| Oct 11, 2012 at 9:15 | vote | accept | Hussain Tamboli | ||
| Oct 12, 2012 at 5:08 | |||||
| Oct 11, 2012 at 9:14 | comment | added | Hussain Tamboli | thanks. the above code really helped. Its too bad getopts doesn't have such provision. What's worse than that is can't upvote you. | |
| Oct 11, 2012 at 9:10 | history | edited | Julian | CC BY-SA 3.0 | added 152 characters in body |
| Oct 11, 2012 at 9:08 | comment | added | Julian | If you want a mandatory option, I don't think thats possible - its probably why they are called options :) You can test $name though, after the loop to make sure it has been set. if [ -z "$name" ] ; then usage; exit ; fi | |
| Oct 11, 2012 at 8:59 | comment | added | Hussain Tamboli | no. its bash. So how do i achieve what I want - handle the no argument condition using bash. | |
| Oct 11, 2012 at 8:57 | history | answered | Julian | CC BY-SA 3.0 |