# |
Date |
Size |
|
Editor |
Comment |
Action |
119 |
2024-02-26 07:51:38 |
8323 |
to previous |
larryv |
replaced bash-hackers URL with Wayback Machine version |
view |
118 |
2021-08-03 18:27:03 |
8279 |
to previous |
GreyCat |
|
view |
117 |
2021-07-26 18:34:34 |
8281 |
to previous |
GreyCat |
Good riddance. |
view |
116 |
2021-07-26 10:52:51 |
8761 |
to previous |
JarnoSuni |
getopt from util-linux supports different styles of long options and options with mandatory and optional arguments. I have used it in my linux-purge script that is meant for Ubuntu Linux. |
view |
115 |
2021-07-26 02:19:37 |
8933 |
to previous |
GreyCat |
a -> an |
view |
114 |
2021-07-26 02:12:39 |
8932 |
to previous |
GreyCat |
Clarify. It's amazing how many people still misunderstand this. |
view |
113 |
2017-06-16 14:17:33 |
7751 |
to previous |
GreyCat |
|
view |
112 |
2017-06-16 14:07:52 |
7755 |
to previous |
GreyCat |
Explain a little more thoroughly. |
view |
111 |
2016-11-30 02:43:23 |
5476 |
to previous |
79 |
|
view |
110 |
2016-11-20 14:44:54 |
5482 |
to previous |
GreyCat |
move yet another crazy thing to ComplexOptionParsing |
view |
109 |
2016-11-19 14:41:40 |
7120 |
to previous |
213-211-57-37 |
fixed a typo |
view |
108 |
2016-11-19 14:40:01 |
7105 |
to previous |
213-211-57-37 |
Added mention about the Argbash utility (incorporated feedback from geirha) |
view |
107 |
2016-09-09 17:23:39 |
5482 |
to previous |
GreyCat |
Clean up the end. |
view |
106 |
2016-07-24 08:44:53 |
5697 |
to previous |
geirha |
this argbash.sh is rather poorly written; using uppercase variable names for internal purposes, missing quotes here and there, inconsistent use of syntax, not testing if cd fails. The list goes on. |
view |
105 |
2016-07-23 19:52:40 |
7247 |
to previous |
213-211-57-37 |
Added mention about the Argbash utility |
view |
- |
2016-07-23 19:45:37 |
2072 |
- |
213-211-57-37 |
ATTNEW: script.sh |
view get |
104 |
2016-02-04 20:23:10 |
5697 |
to previous |
geirha |
Options should not be mandatory/required, they should be *option*al. |
view |
103 |
2016-01-08 23:25:59 |
5765 |
to previous |
geirha |
no point in having this case in particular use continue |
view |
102 |
2015-06-18 19:52:05 |
5793 |
to previous |
GreyCat |
|
view |
101 |
2015-04-29 17:57:43 |
5822 |
to previous |
host-78-147-135-46 |
[igli] as greycat said in edit 87: "command shift" is silly # especially when you're using the vanilla form elsewhere. if your shell can't 'shift' you have bigger problems. |
view |
100 |
2015-04-11 08:25:27 |
5900 |
to previous |
geirha |
Replacing echos with printfs |
view |
99 |
2015-04-07 14:31:53 |
5888 |
to previous |
ormaaj |
And now it's -z! |
view |
98 |
2015-04-07 14:23:26 |
5888 |
to previous |
ormaaj |
Compromising on [ -n "$2" ] after discussion. Also we're not adding unnecessary set -u workarounds. Almost any example would need workarounds to function with it. Feel free to improve FAQ 112. |
view |
97 |
2015-04-07 05:38:57 |
5526 |
to previous |
a91-155-134-37 |
Don't try to evaluate an unset variable. Otherwise the script will exit with error, if set -u is used. |
view |
96 |
2015-04-07 00:19:02 |
5523 |
to previous |
ormaaj |
We want to test for a non-empty argument, not count the number of args. Most shells don't optimize $#. [ involves a pointless copy and some shells pass the -gt args to math evaluation on top of that. |
view |
95 |
2015-01-06 00:21:36 |
5537 |
to previous |
89 |
|
view |
94 |
2015-01-06 00:18:08 |
5541 |
to previous |
89 |
|
view |
93 |
2015-01-05 15:44:14 |
5539 |
to previous |
JarnoSuni |
This is much better programming practice than breaking by using undefined $1 or $2. |
view |
92 |
2015-01-05 14:03:23 |
5548 |
to previous |
ormaaj |
Remove all reference to set -u. It belongs in a dedicated FAQ which discusses what ${1+"$1"} is for, and all the many reasons to hate set -u. |
view |
91 |
2015-01-05 14:01:19 |
6147 |
to previous |
ormaaj |
Reverted. The script was perfect to begin with. I'd have done it last night but it looked like they were still editing. |
view |
90 |
2015-01-05 13:29:08 |
5539 |
to previous |
GreyCat |
OK, fine. You set -u people can have this battle. But not the war. You will NOT get to put set -u at the top of an example. Also, why did you add a second row of category tags, with a duplicate? |
view |
89 |
2015-01-04 23:36:49 |
5606 |
to previous |
JarnoSuni |
Make the script work even with set -o nounset (or set -u) |
view |
88 |
2014-08-07 09:52:57 |
6147 |
to previous |
geirha |
increment verbose |
view |
87 |
2014-07-15 18:18:00 |
6134 |
to previous |
GreyCat |
"command shift" is silly |
view |
86 |
2014-07-04 20:28:52 |
6142 |
to previous |
ormaaj |
Input validation for POSIX example. |
view |
85 |
2014-03-03 11:40:36 |
5776 |
to previous |
geirha |
Changing echos to printfs, and adding a usage function to the getopts example. |
view |
84 |
2014-03-03 09:14:40 |
5275 |
to previous |
geirha |
Manual loop and getopts is enough to answer this faq. Moved the rest to a separate page. |
view |
83 |
2014-02-28 08:36:45 |
12586 |
to previous |
proxy04 |
|
view |
82 |
2013-12-12 10:55:33 |
12584 |
to previous |
StephaneChazelas |
clarification about what POSIX specifies |
view |
81 |
2013-12-12 10:39:13 |
11850 |
to previous |
StephaneChazelas |
util-linux getopt is reliable when properly used. |
view |
80 |
2013-12-12 10:36:28 |
11791 |
to previous |
StephaneChazelas |
sorry, my bad about `-:` trick not working. reverting |
view |
79 |
2013-12-11 22:14:48 |
8324 |
to previous |
188-223-3-27 |
There's no getopts implementation where `-:` works to allow long options. |
view |
78 |
2013-05-06 07:42:24 |
11791 |
to previous |
geirha |
The quotes are unecessary and make it less consistent since not all such assignments were quoted. |
view |
77 |
2013-05-05 13:57:15 |
11795 |
to previous |
p5B0A11F9 |
Add quotes |
view |
76 |
2013-04-11 16:23:26 |
11791 |
to previous |
rrcs-67-52-129-61 |
fix typo |
view |
75 |
2013-03-14 14:15:08 |
11790 |
to previous |
Lhunath |
no need to check for --. |
view |
74 |
2013-02-05 20:38:19 |
11752 |
to previous |
GreyCat |
blank line makes the bot cry |
view |
73 |
2013-02-04 23:53:04 |
11754 |
to previous |
JarnoSuni |
OPTARG=(${@:OPTIND:$((longoptspec[$opt]))}) breaks arguments with whitespace. |
view |
72 |
2012-10-22 20:41:23 |
11126 |
to previous |
GreyCat |
Separate getops long option trickery into its own subsection. Also fix the counting in the set -u bit. |
view |
71 |
2012-09-12 11:59:53 |
11166 |
to previous |
52490F51 |
|
view |