The following issue has been SUBMITTED.
======================================================================
http://austingroupbugs.net/view.php?id=1255
======================================================================
Reported By: stephane
Assigned To:
======================================================================
Project: 1003.1(2016)/Issue7+TC2
Issue ID: 1255
Category: System Interfaces
Type: Enhancement Request
Severity: Objection
Priority: normal
Status: New
Name: Stephane Chazelas
Organization:
User Reference:
Section: glob(), EXAMPLES section
Page Number: 1111 (in the 2018 edition)
Line Number: 37598
Interp Status: ---
Final Accepted Text:
======================================================================
Date Submitted: 2019-06-08 12:31 UTC
Last Modified: 2019-06-08 12:31 UTC
======================================================================
Summary: improper shell code in glob() example
Description:
Even though it is not the main point of that example, the POSIX
specification should avoid showing examples of bad shell coding practice.
Here, that:
ls -l *.c
Should be:
ls -ld -- *.c
As the obvious intention of that code is to list the attributes of the
non-hidden files whose name ends in .c.
The example does say "approximately" which leaves it unclear in which way
it differs. One of the differences in functionality is when the glob
doesn't match any file, which could be easily addressed by adding the
GLOB_NOCHECK flag.
Desired Action:
Replace all occurrences of "ls -l *.c" with "ls -ld -- *.c", "ls -l *.c
*.h" with "ls -ld -- *.c *.h"
Change the first example to:
<pre>
globbuf.gl_offs = 3;
if (glob("*.c", GLOB_DOOFFS|GLOB_NOCHECK, NULL, &globbuf)) abort();
globbuf.gl_pathv[0] = "ls";
globbuf.gl_pathv[1] = "-ld";
globbuf.gl_pathv[2] = "--";
</pre>
The second to:
<pre>
globbuf.gl_offs = 3;
if (glob("*.c", GLOB_DOOFFS|GLOB_NOCHECK, NULL, &globbuf) ||
glob("*.h", GLOB_DOOFFS|GLOB_NOCHECK|GLOB_APPEND, NULL, &globbuf))
abort();
</pre>
Possibly clarify in which way it differs or does not differ from the sh
equivalent. Like state that it should result in the execution of ls with
the same list of arguments.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2019-06-08 12:31 stephane New Issue
2019-06-08 12:31 stephane Name => Stephane Chazelas
2019-06-08 12:31 stephane Section => glob(), EXAMPLES
section
2019-06-08 12:31 stephane Page Number => 1111 (in the 2018
edition)
2019-06-08 12:31 stephane Line Number => 37598
======================================================================