Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-04-20
05:34 • Ticket [e6ca0b1b67] glob inconsistencies on macos status still Closed with 5... artifact: 7e8124a64a user: apnadkarni
2026-04-19
07:32 • Ticket [e6ca0b1b67]: 5 changes artifact: 4ee6c1cb26 user: jmroot
2026-04-17
15:41
Follow-up to [e6ca0b1b67]: Cygwin filesystem is case-insensitive as well check-in: 8ec7452460 user: jan.nijtmans tags: trunk, main
2026-04-14
17:38 • Closed ticket [e6ca0b1b67]: glob inconsistencies on macos plus 5 other chang... artifact: 59888b4b8b user: apnadkarni
17:37 • Ticket [e6ca0b1b67]: 3 changes artifact: c1e14220f0 user: apnadkarni
17:05
Bug [e6ca0b1b67]. MacOS paths should be case insensitive + macos file normalization fix + macos glob... check-in: 8577ad7896 user: apnadkarni tags: trunk, main
2026-04-10
05:14 • Ticket [e6ca0b1b67] glob inconsistencies on macos status still Open with 3 o... artifact: 444e362558 user: apnadkarni
2026-04-01
10:44 • Ticket [e6ca0b1b67]: 4 changes artifact: 8d6c4f11e2 user: jan.nijtmans
08:20 • Ticket [e6ca0b1b67]: 3 changes artifact: 426da51a96 user: apnadkarni
2026-03-31
05:20 • New ticket [e6ca0b1b67]. artifact: 1b76888a0c user: apnadkarni

glob inconsistencies on macos

Closed / Fixede6ca0b1b678f89f0cd6228d9a84604f5a950637aCreated 247 days agoUpdated 227 days ago
Descriptionmarkdown2026-03-31 05:20:16

(Copied from core mailing list)

It seems to me then that Tcl on macos has at least one, and possibly up to three, bugs.

Inconsistent case-sensitivity in matching. I expect

glob /tmp/MIXEDCASE
glob /tmp/M*

both to either include MiXeDcAsE in the return or not, depending on case sensitivity of the file system. But the results do not match. Likewise for

glob /tmp/mixedcase
glob /tmp/m*

I think this is a definite bug because it is inconsistent.

Second possible bug is that Tcl does case-sensitive matching on macos when the expectation is case-insensitive. It's confusing for me because as per Google (and verified by Kevin), modern Macs have case-insensitive file systems by default. Mac users need to comment and take a call on this.

(Not from the tests, but reading the code) file normalize possibly has the same bug it had on Windows where it did not actually normalize to a unique file system representation.

For now, I’m disabling the tests I added on MacOS.

-----Original Message-----
From: Torsten Berg <be...@ty...> 
Sent: Monday, March 30, 2026 11:30 PM
To: <apn...@ya...> <apn...@ya...>
Cc: tcl...@li...
Subject: Re: [TCLCORE] Question for Mac users

Using Tcl 8.6.16 on a macOS using an internal SSD formatted as APFS, not case-sensitive:

() 1 % glob /tmp/MIXEDCASE
/tmp/MIXEDCASE

() 1 % glob /tmp/mixedcase
/tmp/mixedcase

() 1 % glob /tmp/MiXeDcAsE
/tmp/MiXeDcAsE

() 1 % glob /tmp/m*
no files matched glob pattern "/tmp/m*"

 
() 1 % glob /tmp/M*
/tmp/MiXeDcAsE

% tclsh9.1 
% info pa
9.1a1
% glob /tmp/MIXEDCASE
/tmp/MIXEDCASE

Referenced by2
  • 8ec7452460Follow-up to [e6ca0b1b67]: Cygwin filesystem is case-insensitive as well check-in2026-04-17 15:41:40
  • 8577ad7896Bug [e6ca0b1b67]. MacOS paths should be case insensitive + macos file normalization fix + macos glob inconsistency fix. check-in2026-04-14 17:05:55
apnadkarniplain2026-04-01 08:20:38
It appears that the inconsistency between 

```
glob /tmp/MIXEDCASE
glob /tmp/M*
```

occurs because matching code is case-sensitive and existence check is case-insensitive (via lstat on MacOS).

My opinion, as a non-macos user is that the matching code should be changed to be case-insensitive. Though this would be a backward incompatibility, it feels more like a bug fix.
jan.nijtmanswiki2026-04-01 10:44:22

> My opinion, as a non-macos user is that the matching code should be changed to be case-insensitive. Though this would be a backward incompatibility, it feels more like a bug fix.

+1

apnadkarnimarkdown2026-04-10 05:14:31

The apn-mac-case branch now contains proposed fixes for the following, related but independent, issues on MacOS.

  • Inconsistent returns from glob M* and glob MixedCase (original ticket)
  • file normalize does not return the unique name for a file (does not resolve the leaf to its on-disk name)
  • MacOS file paths should be case-insensitive

There is likely to be a (not quantified) performance impact to file normalize on MacOS as it now has to resolve the last path component's real name (just as on Windows). Correctness prevails.

Reviews, particularly from MacOS folks, would be appreciated.

apnadkarniplain2026-04-14 17:37:52
Fixed in [8577ad7896].
apnadkarni Closed ticket [e6ca0b1b67]. [History diff]2026-04-14 17:38:06
jmrootplain2026-04-19 07:32:23
As a macOS user, I think the only way to make `glob` do what the caller wants all the time is to add an explicit `-nocase` option like `string match` has. Case-sensitive matching is what globs in the shell do (even on a case-insensitive FS):

% touch f1 f2 f2 Fa Fb Fc
% ls F*
Fa Fb Fc
% ls f*         
f1 f2 f3

Not being able to match in that way without extra post-processing would be a definite step backwards.

IMO, the behaviour when there is a file called `MixedCase` should be:
glob M* -> MixedCase
glob m* -> 
glob -nocase m* -> MixedCase
glob MIXEDCASE ->
glob -nocase  MIXEDCASE -> MixedCase

HFS+ and APFS come in two flavours, case-sensitive and case-insensitive but case-preserving. Having your main filesystem formatted as case-sensitive is much less common but certainly not unheard of. In both flavours, filenames on disk have a specific case, and I definitely agree that `file normalize` should return that.
apnadkarnimarkdown2026-04-20 05:34:35

The -nocase need (or equivalent fix) is not unique to macos and is logged separately as [a5ba717243]. This branch did not address that. Besides fixing the inconsistency between globbing m* versus mixedcase, it only brings macos into consistency with other Tcl platforms where glob matching is on a per-platform basis, and is based on "general user expectations". Issues related to differing case-sensitivity in file systems are known to be broken functionality.

Case-sensitivity in shells on case-insensitive file systems is broken in the other direction so I'm not sure that is a good example to follow.

glob was never defined to return the on-disk name. If you need that, you have to normalize. The rationale that has been expressed is very often there is no need to incur the cost of that normalization, e.g. foreach f [glob *.bak] {file delete $f} or something like that.

But I agree a more complete solution to the file system casing is required. Hence the aforementioned ticket.

Log in (anonymous is fine) to add a comment.