Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Feb 2023 13:58:11 +0100
From:      Polytropon <freebsd@edvax.de>
To:        "Steve O'Hara-Smith" <steve@sohara.org>
Cc:        questions@FreeBSD.org, Polytropon <freebsd@edvax.de>
Subject:   Re: remove double quote character from file names
Message-ID:  <20230216135811.d4ba5a8c.freebsd@edvax.de>
In-Reply-To: <20230216104927.c96efd845f0714a998b7ae9f@sohara.org>
References:  <d83c93ad-0eac-d41a-c7db-79a1e1bc62d8@nethead.se> <1398045780.627028.1676532009651@ichabod.co-bxl> <20230216112431.8252a3d4.freebsd@edvax.de> <20230216104927.c96efd845f0714a998b7ae9f@sohara.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 16 Feb 2023 10:49:27 +0000, Steve O'Hara-Smith wrote:
> On Thu, 16 Feb 2023 11:24:31 +0100
> Polytropon <freebsd@edvax.de> wrote:
> 
> > exist in the heap of files to be processed. Selecting a good
> > delimiter for input files is hard. Using the "IFS = \n" approach
> > works - as long as there are no newlines in filenames (which
> > I'm not sure could also be allowed)... ;-)
> 
> 	Newlines are indeed allowed in filenames viz:
> 
> ✓ steve@steve ~/tmp $ touch 'a
> file'
> ✓ steve@steve ~/tmp $ echo *
> a
> file
> ✓ steve@steve ~/tmp $ rm 'a
> file' 
> 
> 	There are only two byte values not allowed in the 254 bytes of a
> filename - NUL and /.

AS far as I know, I is "sort of" allowed, because it is subject
to interpretation by the filesystem: it indicates a directory
entry. NUL is actually part of any filename as its terminator,
in terms of common C strings ("blablabla<NUL>").

So in conclusion, not even setting IFS to newline when iterating
over input file lists makes the thing 100 % safe...



> The ls command suppresses most of the nastier
> possibilities and displays a ? these days hence the use of echo above. In
> times past I have constructed confusing directories with the aid of CR and
> BS and even the occasional BEL.

Yes, BEL is great, but so are the new possibilities of UTF-8.
Those byte sequences (which the filesystem doesn't care about
as long as it's not '/' or NUL), especially the many lookalikes
for ';' (greek question mark), ' ' (lots of spaces), or '-'
(lots of dashes, too), bear a huge potential for confusion
or fun, depending on what side you are on, user or sysadmin.
Files like "     " (invisible) or "*.txt" are possible, and
I assume there is even a symbol that looks like '/', so maybe
a file that looks (!) like "not/a/directory.c" could be created.
The times when seeing LOGIN.COM;1 or SYS1.PARMLIB(IEASYS00)
or BOB::SYSMGR$DKA300:[HOME.BOB.SRC.MEOW]STUPID.TXT;42 on
a UNIX filesystem were a bit of a surprise are long gone.
Long live invisible files! :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20230216135811.d4ba5a8c.freebsd>