Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Such a lovely explanation, thank you. Insight into the getopt() level of parsing is especially helpful. In my head scratchings I'd completely forgotten about the possibility of -t0.05 (no space) and what that implies, too. Great stuff! Commented Sep 1, 2021 at 11:57
  • Yah, it boils down to date scanning integer arguments with ` %d` optional-leading-whitespace-then-a-decimal-integer and read scanning them with %d, just decimal-integer, no leading whitespace accepted. read -t ' 1' gets rejected too. Commented Sep 1, 2021 at 19:37
  • @jthill, except that scanf("%d") accepts and discards leading whitespace. The POSIX description says "Input white-space characters (as specified by isspace) shall be skipped, unless the conversion specification includes a [, c, C, or n conversion specifier." Also, %d wouldn't do, since it can take a fractional number. Bash uses its own code for parsing that. Commented Sep 2, 2021 at 14:45