chilcote / outset

Automatically process packages, profiles, and scripts during boot, login, or on demand.
572 stars 58 forks source link

directory listings should be sorted #48

Closed dhmoore closed 7 years ago

dhmoore commented 7 years ago

In testing High Sierra on APFS, I found that my outset login-once scripts did not run in alphabetical order. I tested os.listdir in the system's Python 2.7 and other directory listings were in random order, too.

At first I thought this might be an OS bug, but the docs for os.listdir state that the listing is in arbitrary order. https://docs.python.org/2/library/os.html

chilcote commented 7 years ago

Can you try the latest commit(s) in Hi-C please?

https://github.com/chilcote/outset/commit/5188911e67d868660cbd5961cd34c18c257d7e3f

dhmoore commented 7 years ago

Filenames starting with numbers ran first in the correct order, then upper-case in alphabetical order, then lowercase in alphabetical order.

arubdesu commented 7 years ago

Yay, so it would seem the docs are accurate on Hi-C now as well?

dhmoore commented 7 years ago

Doesn't look like it. The answer for that Q says "a file starting with 000 will be evaluated before one that starts with 0a, after which would be files like aaa that start with lowercase characters, then capitalized files AAA."

I found that upper-case-files ran before lower-case.

chilcote commented 7 years ago

That's true. It seems os.walk was doing things oddly even pre Hi-C. I think the new way of sorting capitalized before lowercase is preferable, and is more in line with what I'd expect. For example:

>>> l = ['001', '010', '002', 'aaa', 'AAAA', 'A101', 'A001', 'A002', 'a001', 'a100']
>>> print l
['001', '010', '002', 'aaa', 'AAAA', 'A101', 'A001', 'A002', 'a001', 'a100']
>>> l.sort()
>>> print l
['001', '002', '010', 'A001', 'A002', 'A101', 'AAAA', 'a001', 'a100', 'aaa']

What say we update the docs to reflect the new correct behavior?

dhmoore commented 7 years ago

Your call, but I would worry that some people depend on the current documented order. Also, for updated documentation, you might want to specify how Outset's behavior relates to other ways of viewing file listings. The new behavior matches the way ls sorts, but Finder listings are case-insensitive (at least for non-case-sensitive HFS+).

erikng commented 7 years ago

I think it should be expected that file directory listings are going to be changing for 10.13 and people should expect these changes.

If they are blindly updating outset to their fleet and not testing, the onus is on them.

Thanks, Erik Gomez


From: dhmoore notifications@github.com Sent: Tuesday, June 27, 2017 10:07:55 AM To: chilcote/outset Cc: Subscribed Subject: Re: [chilcote/outset] directory listings should be sorted (#48)

Your call, but I would worry that some people depend on the documented order. Also, for documentation, you might want to specify how Outset's behavior relates to other ways of viewing file listings. The new behavior matches the way ls sorts, but Finder listings are case-insensitive (at least for non-case-sensitive HFS+).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/chilcote/outset/issues/48#issuecomment-311388346, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFa_GKW_7XaM2verwtkU3kuoe5-66nT2ks5sIRrLgaJpZM4Nyp2N.

chilcote commented 7 years ago

Agreed

pixelrebel commented 5 years ago

While scripts may execute in order, they only do so in their groups. The following scripts:

/usr/local/outset/login-privileged-once/10-privileged.sh
/usr/local/outset/login-once/20-unprivileged.sh

actually execute in the following order:

/usr/local/outset/login-once/20-unprivileged.sh
/usr/local/outset/login-privileged-once/10-privileged.sh

How do I get login-privileged-once scripts to execute before login-once scripts?

chilcote commented 5 years ago

You'll want to change the order here https://github.com/chilcote/outset/blob/master/pkgroot/usr/local/outset/outset#L423-L428