You pays your money and you takes your pick: Yes, No, Maybe.
It comes down to your definition of 'extension'.
- Is it "anything after the last dot in the name"? If so, those files have no name and are all extension.
- Is it "anything after a dot that isn't the first character in the name"? If so, those files don't have an extension.
- If you use some other definition, then the answer will need to be adjusted accordingly.
Remember that SCCS files used a prefix s.
(amongst others; you'd see p.
files too — and there were many transient file names with other prefixes). Does an SCCS file s.something
have an extension or a prefix? (With s.source.c
, it is reasonably straight-forward; there's a prefix, a name and an extension or suffix, or you could ignore the prefix as a special case and the name is s.source
and the extension is .c
.) What about the default executable name, a.out
? What about a name such as ..dot
; does it have an extension, and if so, what is it?
Note that the answer on DOS was more formalized. There the file system used to enforce (once upon another millennium or so) names with 8.3 and the extension was tangible. But that's a bygone era for the most part (and there are few who miss it).
Anthony Arnold and paxdiablo both noted that names ending with .tar.gz
exist — what's the extension on such files?
If you treat the extension of somecode-8.76.tar.gz
as anything other than .gz
, you are opening yourself up to a bag'o'worms. The contained file is somecode-8.76.tar
; that itself can be reasonably said to have an extension of .tar
. Defining the extension of the whole gzipped tar file as .tar.gz
raises the question of "why isn't it .76.tar.gz
" and also means that you need to revisit the SCCS file naming convention. Absorbing the .76
portion of the name into either .76.tar.gz
or .76.tar
as a suffix is making life complex indeed. It's a valid question, but anything other than "an extension is the string from the last dot to the end of the name" is fraught indeed — or requires interpretation of the meaning of the extension, and gets into another complex area that it generally is better to avoid.
Note that Unix at the O/S or file system level doesn't care about the extension on files. Programs can decide they care about extensions, but that's up to the program. The extension is an indicator of the file type; it is not definitive. That's why the file
program exists to identify the contents of files. It looks at the contents of the file to identify the content; it doesn't pay attention to the file extension (so it doesn't have to decide what the extension is, either).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…