Original submission from rea@
Details
- Reviewers
• rea bapt jilles - Group Reviewers
manpages - Commits
- rG2980318b2747: sh.1: extend the section about getopts
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
bin/sh/sh.1 | ||
---|---|---|
2390 | I don't disagree and I'm open to suggestions, but FWIW, POSIX uses simiar wording:
Although they do specify what it is that specifies. I'll wait and collect more suggestions, then try to make further improvements |
bin/sh/sh.1 | ||
---|---|---|
2390 | this suggests "for an unknown option" to be easier to approach but jilles' is more correct and useful once you're past the basics. |
getopts optstring var Parse command-line options and arguments. The first argument optstring should be a series of letters, each possibly followed by a colon which indicates that the option takes an argument. The specified variable var is set to the parsed option. The index of the next argument is placed into the shell variable OPTIND. If an option takes an argument, it is placed into the shell variable OPTARG. If the found character is not specified by optstring or if it is missing a required argument, the option is considered invalid and: If the first character of optstring is not a colon then OPTARG is unset, var is set to ‘?’ and a diagnostic message is written to stderr. If the first character of optstring is a colon then OPTARG is set to the the option character found, var is set to ‘:’ when a required argument is missing or to ‘?’ when the option was not specified by optstring, and no diagnostic message is written to stderr. getopts returns a false value (1) when it encounters the end of the options. A new set of arguments may be parsed by assigning OPTIND=1. The POSIX getopts command deprecates the older getopt(1) command.
bin/sh/sh.1 | ||
---|---|---|
2388 | stderr has a manual, you could optionally crossreference to that if you want. |
bin/sh/sh.1 | ||
---|---|---|
2383 | These are environment variables? I think Ev is a special macro for environment variables. |
bin/sh/sh.1 | ||
---|---|---|
2358–2359 | I moved it to to the sentence about "POSIX getopts" obsoleting geptopt. I feel that was the intent of the original phrasing. I kept the two pieces of information, but moved it to the very end of this section. I don't think we need or want to remove it altogether. | |
2383 | I think I can agree, I can change that before committing if I don't forget. | |
2388 | I think it depends on what makes a term worth of cross-referencing. I think if someone is reading sh.1, they already know perfectly well what stderr is, so I wouldn't "fix what isn't broken". But if there is a good reason to cross-refer it and I just don't know it, I have no strong opinions either way. |
bin/sh/sh.1 | ||
---|---|---|
2388 |
Please consider that this is unlikely today for the first time reader in the current climate. I am 29. I first installed FreeBSD on my parents old computer when I was 12. I learned what sh was long before stderr because informal learning is via "what's this?". The default MOTD, the only instruction the system gives a new user, does say "Introduction to manual pages:" at the bottom. On the discord we have a steady stream of such kids. |
bin/sh/sh.1 | ||
---|---|---|
2383 | I changed my mind about this, I don't know enough to make a decision and it's out of scope of this change anyway. |