ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: john@hawthorn.email
To: ruby-core@ruby-lang.org
Subject: [ruby-core:96828] [Ruby master Feature#8709] Dir.glob should return sorted file list
Date: Mon, 13 Jan 2020 18:49:45 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-83826.20200113184944.08c76d520f95a1b6@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-8709.20130731012405@ruby-lang.org

Issue #8709 has been updated by jhawthorn (John Hawthorn).


One potential issue with this is that though globs which scanned directories (ex. `Dir.glob("foo/*")`) would return results in an inconsistent order, globs which used purely brace expansion (ex. `Dir.glob("foo/{a,b,c,d}")`) would return values predictably in the order listed.

Rails versions prior to 6.0 unfortunately relied on this behaviour (6.0+ in *most* cases doesn't and does sorting manually). It probably shouldn't have relied on it, but it did, and I fear other libraries or tools may have done the same.

We could possibly work around that by sorting when reading directory entries rather than sorting the full result, but that's more complicated to implement and would be hard to document as an exact behaviour developers can expect/rely upon.

----------------------------------------
Feature #8709: Dir.glob should return sorted file list
https://bugs.ruby-lang.org/issues/8709#change-83826

* Author: tommorris (Tom Morris)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
On OS X, Dir.glob and Dir[] return an ordered list of files.

On Ubuntu Linux, they do not and one must manually sort them.

Returning a list of files that isn't in order fails the Principle of Least Astonishment.

I attach a unit test to demonstrate ideal behaviour.

---Files--------------------------------
globtest.rb (454 Bytes)


-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2020-01-13 18:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30 16:24 [ruby-core:56274] [ruby-trunk - Bug #8709][Open] Dir.glob should return sorted file list tommorris (Tom Morris)
2013-07-30 17:49 ` [ruby-core:56275] [ruby-trunk - Bug #8709][Rejected] " charliesome (Charlie Somerville)
2020-01-11  6:28 ` [ruby-core:96776] [Ruby master Bug#8709] " rubybugsbmw
2020-01-11 11:18 ` [ruby-core:96779] " hsbt
2020-01-11 11:27 ` [ruby-core:96780] [Ruby master Feature#8709] " eregontp
2020-01-11 11:32 ` [ruby-core:96781] " hsbt
2020-01-11 11:33 ` [ruby-core:96782] " eregontp
2020-01-11 11:35 ` [ruby-core:96785] " eregontp
2020-01-11 20:48 ` [ruby-core:96792] " rubybugsbmw
2020-01-13  9:28 ` [ruby-core:96823] " jean.boussier
2020-01-13 10:04 ` [ruby-core:96824] " deivid.rodriguez
2020-01-13 18:49 ` john [this message]
2020-01-14  6:27 ` [ruby-core:96836] " naruse
2020-01-14  7:27 ` [ruby-core:96840] " mame
2020-01-14 10:40 ` [ruby-core:96850] " eregontp
2020-01-14 10:44 ` [ruby-core:96851] " eregontp
2020-01-16  5:22 ` [ruby-core:96882] " nobu
2020-01-16  6:03 ` [ruby-core:96888] " matz
2020-01-16 15:12 ` [ruby-core:96911] " daniel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-83826.20200113184944.08c76d520f95a1b6@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).