At Thu, 21 Mar 2019 05:44:24 -0700 (PDT) Alexandru <
alexandr...@meshparts.de> wrote:
>
> Am Donnerstag, 21. M=C3=A4rz 2019 13:40:12 UTC+1 schrieb Robert Heller:
> > At Wed, 20 Mar 2019 18:43:15 -0700 (PDT) Alexandru <alexandru.dadalau@mes=
>
hparts.de> wrote:
> >=20
> > >=20
> > > Am Mittwoch, 20. M=3DC3=3DA4rz 2019 18:49:09 UTC+1 schrieb Rich:
> > > > Alexandru <
alexandr...@meshparts.de> wrote:
> > > >=3D20
> > > > *CRITICALLY IMPORTANT* bit of detail missing:
> > > >=3D20
> > > > What Operating System?
> > >=20
> > > Yes, it's Windows, sorry for writing this only in the title.
> > >=20
> > > >=3D20
> > > > > Suppose I have a file named=3D20
> > > > >=3D20
> > > > > My_file.txt
> > > > >=3D20
> > > > > and want to use "glob" to find it in different situations (which=3D=
> 20
> > > > > differ by the ammount of knowledge about the full file name):
> > > > >=3D20
> > > > > glob my*.txt
> > > > >>> My_file.txt
> > > > >=3D20
> > > > > glob My*.txt
> > > > >>> My_file.txt
> > > > >=3D20
> > > > > Until now everything is as expected.
> > > >=3D20
> > > > Only if you are using an OS with an inferior case-folding filesystem.=
> =3D20
> > > > Below is what is *expected* from a proper filesystem:
> > > >=3D20
> > > > $ ls -l=3D20
> > > > total 0
> > > > -rw-r--r-- 1 _____ _____ 0 Mar 20 13:40 My_file.txt
> > > > $ rlwrap tclsh=3D20
> > > > % glob my*.txt
> > > > no files matched glob pattern "my*.txt"
> > > > % glob My*.txt
> > > > My_file.txt
> > >=20
> > > The "inferior" file system is actually making my life easier in this ca=
> se. =3D
> > > Like I said, I don't know the case folding and I was trying to find it =
> out =3D
> > > using the glob command. I won't do this anymore since now I know brim B=
> rad =3D
> > > that I can use file normalize.
> > >=20
> > > BTW: On "superior" file systems I would complain that there is no "-noc=
> ase"=3D
> > > option in the "glob" command. Perhaps glob can be enhanced with both -=
> noca=3D
> > > se and case folding in the next release.
> >=20
> > glob {[Mm][Yy]_[Ff][Ii][Ll][Ee].[Tt][Xx][Tt]}
> >=20
> > And one can always write a simple wrapper proc to "expand" a filename to =
> the=20
> > above form:
> >=20
> > proc glob-nocase {filename} {
> > set resultname {}
> > foreach c [split $filename {}] {
> > if {[string is alpha $c]} {
> > append resultname {[} [string toupper $c] [string tolower $c] {=
> ]}
> > } else {
> > append resultname $c
> > }
> > }
> > return [glob $resultname]
> > }
> >=20
> > (Ideally the above should be written to allow for glob's options, but I'l=
> l=20
> > leave that as an exercise for the reader.)
> >=20
> > >=20
> > > >=3D20
> > > > > Note that even if I change the=3D20
> > > > > letter case in the glob pattern, the returned value is consistent=
> =3D20
> > > > > with the letter case in the file name.
> > > >=3D20
> > > > Which implies you are on Windows or Mac, with their case folding=3D20
> > > > filesystems, where each of: My_file.txt, MY_FILE.TXT, my_file.txt,=3D=
> 20
> > > > etc., all refer to the same filename on disk.
> > > >=3D20
> > > > > But if I want to use the glob to find out how the letter case of a=
> =3D20
> > > > > file is (I know the name but not the letter case):
> > > > >=3D20
> > > > > glob My_file.txt
> > > > >>> My_file.txt
> > > > >=3D20
> > > > > glob MY_FILE.txt
> > > > >>> MY_FILE.txt
> > > > >=3D20
> > > > > The result will be the input value. I guess, internally glob check=
> s=3D20
> > > > > if the file has any wild cards. If not it checks if the file exist=
> s=3D20
> > > > > and if yes it returns the initial argument not the true name of the=
> =3D20
> > > > > file.
> > > >=3D20
> > > > No. You are being fooled by the case folding filesystem. With a=3D2=
> 0
> > > > proper filesystem, things work as expected:
> > > >=3D20
> > > > $ ls -l=3D20
> > > > total 0
> > > > -rw-r--r-- 1 ______ _____ 0 Mar 20 13:40 My_file.txt
> > > > $ rlwrap tclsh=3D20
> > > > % glob my*.txt
> > > > no files matched glob pattern "my*.txt"
> > > > % glob My*.txt
> > > > My_file.txt
> > > > % glob My_file.txt
> > > > My_file.txt
> > > > % glob MY_FILE.txt
> > > > no files matched glob pattern "MY_FILE.txt"
> > > > %=3D20
> > > >=3D20
> > > > > It would be better to always return the true name of the file=3D20
> > > > > considering the leter case.
> > > > >=3D20
> > > > > What do you think?
> > > >=3D20
> > > > It would be better to not use an OS with a case folding filesystem. =
> =3D20
> > > > Then you get what you expect.
> > >=20
> > >=20
> > > I appreciate your opinion but having a case sensitive file system is no=
> t on=3D
> > > my wish list for Windows. Reason: If I would have two files with same =
> name=3D
> > > but different case folding in the same directory, after one year I wou=
> ld n=3D
> > > ot remember, which file is that I'm looking for. The letter case is ver=
> y he=3D
> > > lpful when writing code, but not for every day use in the office. Since=
> not=3D
> > > everybody is a programmer, I thing Microsoft made a very wise decision=
> not=3D
> > > to include the case folding.
> >=20
> > It would be *dumb* to use case alone to distinguish files.
> >=20
> > >=20
> > > >=3D20
> > > > The fact is, the bug here is in your chosen OS, not in Tcl.
> > >=20
> > > Never said this is a bug. I also don't think this is a bug. That said, =
> this=3D
> > > proposal should be seen as an enhancement for the glob command, as Bra=
> d al=3D
> > > ready said.
> > > =
> =20
> >=20
> > --=20
> So I'm extracting from your answer, that you don't agree with the proposed =
> enhancement of the glob command?
No, I don't see it as a useful or necessary enhancement. There are other ways
to handle things using the existing code.