deterministic order for include by wildcard
Hey folks, Do wildcards in includes resolve in a deterministic order? I'd like to just put something like the following in my bird.conf: include "/etc/bird.d/*.conf" If I do that, can I rely on 10-common.conf to be included before 20-bgp_to_other_place.conf so that I can define templates in a common place and use those templated in the later included files? If there is a deterministic order, it might make sense to identify that order in the docs. I only found [1], which does not say anything about the order of the files included. Also, if the ordering does exist, does anything affect the ordering? As a side note, it would also be nice to add an anchor to each option in the different sections where there are options so that one could link directly to the option within the section. If that had existed, I could have linked to the "include" option directly. Is there a bug tracker somewhere for bird for this type of request? Thanks, wt [1]http://bird.network.cz/?get_doc&f=bird-3.html#ss3.2 at the "include" option
According to an IRC discussion with someone named Elrond: <Elrond> rv = glob(patt, GLOB_ERR | GLOB_NOESCAPE, NULL, &g); <Elrond> char *fname = g.gl_pathv[i]; This seems good to me. Seems like it might be useful to mention that the glob is sorted in the docs. wt On Mon, Dec 28, 2015 at 10:32 AM, Warren Turkal <wt@penguintechs.org> wrote:
Hey folks,
Do wildcards in includes resolve in a deterministic order? I'd like to just put something like the following in my bird.conf:
include "/etc/bird.d/*.conf"
If I do that, can I rely on 10-common.conf to be included before 20-bgp_to_other_place.conf so that I can define templates in a common place and use those templated in the later included files?
If there is a deterministic order, it might make sense to identify that order in the docs. I only found [1], which does not say anything about the order of the files included.
Also, if the ordering does exist, does anything affect the ordering?
As a side note, it would also be nice to add an anchor to each option in the different sections where there are options so that one could link directly to the option within the section. If that had existed, I could have linked to the "include" option directly.
Is there a bug tracker somewhere for bird for this type of request?
Thanks, wt
[1]http://bird.network.cz/?get_doc&f=bird-3.html#ss3.2 at the "include" option
On Mon, Dec 28, 2015 at 10:32:37AM -0800, Warren Turkal wrote:
Hey folks,
Do wildcards in includes resolve in a deterministic order? I'd like to just put something like the following in my bird.conf:
include "/etc/bird.d/*.conf"
If I do that, can I rely on 10-common.conf to be included before 20-bgp_to_other_place.conf so that I can define templates in a common place and use those templated in the later included files?
Also, if the ordering does exist, does anything affect the ordering?
Hi Results are alphabetically sorted. The wildcard expansion is implemented by standard glob() libc function, and unfortunately both Single UNIX specification and GNU C library documentation are lacking details about that. I would expect that it is a plain ASCII, non-localized alphabetic sort.
If there is a deterministic order, it might make sense to identify that order in the docs. I only found [1], which does not say anything about the order of the files included.
Will fix that.
As a side note, it would also be nice to add an anchor to each option in the different sections where there are options so that one could link directly to the option within the section. If that had existed, I could have linked to the "include" option directly.
A good idea.
Is there a bug tracker somewhere for bird for this type of request?
Not really. There is a bug tracker as a part of gitlab package used for BIRD, but it is not much used. I generally prefer bugs and requests to be are discussed on the mailing list. But for trivial fixes and subsequent progress tracking using bug tracker makes sense, so perhaps we could start to use it. -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
On Mon, 28 Dec 2015, Ondrej Zajicek wrote:
Results are alphabetically sorted. The wildcard expansion is implemented by standard glob() libc function, and unfortunately both Single UNIX specification and GNU C library documentation are lacking details about that. I would expect that it is a plain ASCII, non-localized alphabetic sort.
In glibc, glob() is locale-aware and it will use the locale's collating order. Refer to glibc source, posix/glob.c, around line 1247: 1247 if (!(flags & GLOB_NOSORT)) 1248 { 1249 /* Sort the vector. */ 1250 qsort (&pglob->gl_pathv[oldcount], 1251 pglob->gl_pathc + pglob->gl_offs - oldcount, 1252 sizeof (char *), collated_compare); 1253 } ... 1288 static int 1289 collated_compare (const void *a, const void *b) 1290 { 1291 const char *const s1 = *(const char *const * const) a; 1292 const char *const s2 = *(const char *const * const) b; 1293 1294 if (s1 == s2) 1295 return 0; 1296 if (s1 == NULL) 1297 return 1; 1298 if (s2 == NULL) 1299 return -1; 1300 return strcoll (s1, s2); 1301 } That said, glibc will default the entire program to the C locale (or maybe C.UTF-8 nowadays), unless setlocale() has been called. If you are working in an unknown locale, though (e.g. setlocale() was called to set the process locale to the system's locale), do *NOT* assume the sorting will look like what you'd get out of ASCII.
Not really. There is a bug tracker as a part of gitlab package used for BIRD, but it is not much used. I generally prefer bugs and requests to be are discussed on the mailing list. But for trivial fixes and subsequent progress tracking using bug tracker makes sense, so perhaps we could start to use it.
IME, you will find that without a bug tracker you will eventually have bug reports falling through the cracks, and that "some things that should not have been forgotten were lost." -- "One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
On Mon, Dec 28, 2015 at 08:42:19PM -0200, Henrique de Moraes Holschuh wrote:
On Mon, 28 Dec 2015, Ondrej Zajicek wrote:
Results are alphabetically sorted. The wildcard expansion is implemented by standard glob() libc function, and unfortunately both Single UNIX specification and GNU C library documentation are lacking details about that. I would expect that it is a plain ASCII, non-localized alphabetic sort.
In glibc, glob() is locale-aware and it will use the locale's collating order. ... That said, glibc will default the entire program to the C locale (or maybe C.UTF-8 nowadays), unless setlocale() has been called.
If you are working in an unknown locale, though (e.g. setlocale() was called to set the process locale to the system's locale), do *NOT* assume the sorting will look like what you'd get out of ASCII.
That is true, but we do not call setlocale(). That is the reason why i would expect it to be a plain ASCII, non-localized alphabetic sort. -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
participants (3)
-
Henrique de Moraes Holschuh -
Ondrej Zajicek -
Warren Turkal