file.man 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. .\" $File: file.man,v 1.133 2018/10/01 18:51:39 christos Exp $
  2. .Dd October 1, 2018
  3. .Dt FILE __CSECTION__
  4. .Os
  5. .Sh NAME
  6. .Nm file
  7. .Nd determine file type
  8. .Sh SYNOPSIS
  9. .Nm
  10. .Bk -words
  11. .Op Fl bcdEhiklLNnprsSvzZ0
  12. .Op Fl Fl apple
  13. .Op Fl Fl extension
  14. .Op Fl Fl mime-encoding
  15. .Op Fl Fl mime-type
  16. .Op Fl e Ar testname
  17. .Op Fl F Ar separator
  18. .Op Fl f Ar namefile
  19. .Op Fl m Ar magicfiles
  20. .Op Fl P Ar name=value
  21. .Ar
  22. .Ek
  23. .Nm
  24. .Fl C
  25. .Op Fl m Ar magicfiles
  26. .Nm
  27. .Op Fl Fl help
  28. .Sh DESCRIPTION
  29. This manual page documents version __VERSION__ of the
  30. .Nm
  31. command.
  32. .Pp
  33. .Nm
  34. tests each argument in an attempt to classify it.
  35. There are three sets of tests, performed in this order:
  36. filesystem tests, magic tests, and language tests.
  37. The
  38. .Em first
  39. test that succeeds causes the file type to be printed.
  40. .Pp
  41. The type printed will usually contain one of the words
  42. .Em text
  43. (the file contains only
  44. printing characters and a few common control
  45. characters and is probably safe to read on an
  46. .Dv ASCII
  47. terminal),
  48. .Em executable
  49. (the file contains the result of compiling a program
  50. in a form understandable to some
  51. .Tn UNIX
  52. kernel or another),
  53. or
  54. .Em data
  55. meaning anything else (data is usually
  56. .Dq binary
  57. or non-printable).
  58. Exceptions are well-known file formats (core files, tar archives)
  59. that are known to contain binary data.
  60. When modifying magic files or the program itself, make sure to
  61. .Em "preserve these keywords" .
  62. Users depend on knowing that all the readable files in a directory
  63. have the word
  64. .Dq text
  65. printed.
  66. Don't do as Berkeley did and change
  67. .Dq shell commands text
  68. to
  69. .Dq shell script .
  70. .Pp
  71. The filesystem tests are based on examining the return from a
  72. .Xr stat 2
  73. system call.
  74. The program checks to see if the file is empty,
  75. or if it's some sort of special file.
  76. Any known file types appropriate to the system you are running on
  77. (sockets, symbolic links, or named pipes (FIFOs) on those systems that
  78. implement them)
  79. are intuited if they are defined in the system header file
  80. .In sys/stat.h .
  81. .Pp
  82. The magic tests are used to check for files with data in
  83. particular fixed formats.
  84. The canonical example of this is a binary executable (compiled program)
  85. .Dv a.out
  86. file, whose format is defined in
  87. .In elf.h ,
  88. .In a.out.h
  89. and possibly
  90. .In exec.h
  91. in the standard include directory.
  92. These files have a
  93. .Dq "magic number"
  94. stored in a particular place
  95. near the beginning of the file that tells the
  96. .Tn UNIX
  97. operating system
  98. that the file is a binary executable, and which of several types thereof.
  99. The concept of a
  100. .Dq "magic"
  101. has been applied by extension to data files.
  102. Any file with some invariant identifier at a small fixed
  103. offset into the file can usually be described in this way.
  104. The information identifying these files is read from the compiled
  105. magic file
  106. .Pa __MAGIC__.mgc ,
  107. or the files in the directory
  108. .Pa __MAGIC__
  109. if the compiled file does not exist.
  110. In addition, if
  111. .Pa $HOME/.magic.mgc
  112. or
  113. .Pa $HOME/.magic
  114. exists, it will be used in preference to the system magic files.
  115. .Pp
  116. If a file does not match any of the entries in the magic file,
  117. it is examined to see if it seems to be a text file.
  118. ASCII, ISO-8859-x, non-ISO 8-bit extended-ASCII character sets
  119. (such as those used on Macintosh and IBM PC systems),
  120. UTF-8-encoded Unicode, UTF-16-encoded Unicode, and EBCDIC
  121. character sets can be distinguished by the different
  122. ranges and sequences of bytes that constitute printable text
  123. in each set.
  124. If a file passes any of these tests, its character set is reported.
  125. ASCII, ISO-8859-x, UTF-8, and extended-ASCII files are identified
  126. as
  127. .Dq text
  128. because they will be mostly readable on nearly any terminal;
  129. UTF-16 and EBCDIC are only
  130. .Dq character data
  131. because, while
  132. they contain text, it is text that will require translation
  133. before it can be read.
  134. In addition,
  135. .Nm
  136. will attempt to determine other characteristics of text-type files.
  137. If the lines of a file are terminated by CR, CRLF, or NEL, instead
  138. of the Unix-standard LF, this will be reported.
  139. Files that contain embedded escape sequences or overstriking
  140. will also be identified.
  141. .Pp
  142. Once
  143. .Nm
  144. has determined the character set used in a text-type file,
  145. it will
  146. attempt to determine in what language the file is written.
  147. The language tests look for particular strings (cf.
  148. .In names.h )
  149. that can appear anywhere in the first few blocks of a file.
  150. For example, the keyword
  151. .Em .br
  152. indicates that the file is most likely a
  153. .Xr troff 1
  154. input file, just as the keyword
  155. .Em struct
  156. indicates a C program.
  157. These tests are less reliable than the previous
  158. two groups, so they are performed last.
  159. The language test routines also test for some miscellany
  160. (such as
  161. .Xr tar 1
  162. archives, JSON files).
  163. .Pp
  164. Any file that cannot be identified as having been written
  165. in any of the character sets listed above is simply said to be
  166. .Dq data .
  167. .Sh OPTIONS
  168. .Bl -tag -width indent
  169. .It Fl Fl apple
  170. Causes the file command to output the file type and creator code as
  171. used by older MacOS versions.
  172. The code consists of eight letters,
  173. the first describing the file type, the latter the creator.
  174. .It Fl b , Fl Fl brief
  175. Do not prepend filenames to output lines (brief mode).
  176. .It Fl C , Fl Fl compile
  177. Write a
  178. .Pa magic.mgc
  179. output file that contains a pre-parsed version of the magic file or directory.
  180. .It Fl c , Fl Fl checking-printout
  181. Cause a checking printout of the parsed form of the magic file.
  182. This is usually used in conjunction with the
  183. .Fl m
  184. flag to debug a new magic file before installing it.
  185. .It Fl d
  186. Prints internal debugging information to stderr.
  187. .It Fl E
  188. On filesystem errors (file not found etc), instead of handling the error
  189. as regular output as POSIX mandates and keep going, issue an error message
  190. and exit.
  191. .It Fl e , Fl Fl exclude Ar testname
  192. Exclude the test named in
  193. .Ar testname
  194. from the list of tests made to determine the file type.
  195. Valid test names are:
  196. .Bl -tag -width compress
  197. .It apptype
  198. .Dv EMX
  199. application type (only on EMX).
  200. .It ascii
  201. Various types of text files (this test will try to guess the text
  202. encoding, irrespective of the setting of the
  203. .Sq encoding
  204. option).
  205. .It encoding
  206. Different text encodings for soft magic tests.
  207. .It tokens
  208. Ignored for backwards compatibility.
  209. .It cdf
  210. Prints details of Compound Document Files.
  211. .It compress
  212. Checks for, and looks inside, compressed files.
  213. .It elf
  214. Prints ELF file details, provided soft magic tests are enabled and the
  215. elf magic is found.
  216. .It json
  217. Examines JSON (RFC-7159) files by parsing them for compliance.
  218. .It soft
  219. Consults magic files.
  220. .It tar
  221. Examines tar files by verifying the checksum of the 512 byte tar header.
  222. Excluding this test can provide more detailed content description by using
  223. the soft magic method.
  224. .It text
  225. A synonym for
  226. .Sq ascii .
  227. .El
  228. .It Fl Fl extension
  229. Print a slash-separated list of valid extensions for the file type found.
  230. .It Fl F , Fl Fl separator Ar separator
  231. Use the specified string as the separator between the filename and the
  232. file result returned.
  233. Defaults to
  234. .Sq \&: .
  235. .It Fl f , Fl Fl files-from Ar namefile
  236. Read the names of the files to be examined from
  237. .Ar namefile
  238. (one per line)
  239. before the argument list.
  240. Either
  241. .Ar namefile
  242. or at least one filename argument must be present;
  243. to test the standard input, use
  244. .Sq -
  245. as a filename argument.
  246. Please note that
  247. .Ar namefile
  248. is unwrapped and the enclosed filenames are processed when this option is
  249. encountered and before any further options processing is done.
  250. This allows one to process multiple lists of files with different command line
  251. arguments on the same
  252. .Nm
  253. invocation.
  254. Thus if you want to set the delimiter, you need to do it before you specify
  255. the list of files, like:
  256. .Dq Fl F Ar @ Fl f Ar namefile ,
  257. instead of:
  258. .Dq Fl f Ar namefile Fl F Ar @ .
  259. .It Fl h , Fl Fl no-dereference
  260. option causes symlinks not to be followed
  261. (on systems that support symbolic links).
  262. This is the default if the environment variable
  263. .Dv POSIXLY_CORRECT
  264. is not defined.
  265. .It Fl i , Fl Fl mime
  266. Causes the file command to output mime type strings rather than the more
  267. traditional human readable ones.
  268. Thus it may say
  269. .Sq text/plain; charset=us-ascii
  270. rather than
  271. .Dq ASCII text .
  272. .It Fl Fl mime-type , Fl Fl mime-encoding
  273. Like
  274. .Fl i ,
  275. but print only the specified element(s).
  276. .It Fl k , Fl Fl keep-going
  277. Don't stop at the first match, keep going.
  278. Subsequent matches will be
  279. have the string
  280. .Sq "\[rs]012\- "
  281. prepended.
  282. (If you want a newline, see the
  283. .Fl r
  284. option.)
  285. The magic pattern with the highest strength (see the
  286. .Fl l
  287. option) comes first.
  288. .It Fl l , Fl Fl list
  289. Shows a list of patterns and their strength sorted descending by
  290. .Xr magic 4
  291. strength
  292. which is used for the matching (see also the
  293. .Fl k
  294. option).
  295. .It Fl L , Fl Fl dereference
  296. option causes symlinks to be followed, as the like-named option in
  297. .Xr ls 1
  298. (on systems that support symbolic links).
  299. This is the default if the environment variable
  300. .Ev POSIXLY_CORRECT
  301. is defined.
  302. .It Fl m , Fl Fl magic-file Ar magicfiles
  303. Specify an alternate list of files and directories containing magic.
  304. This can be a single item, or a colon-separated list.
  305. If a compiled magic file is found alongside a file or directory,
  306. it will be used instead.
  307. .It Fl N , Fl Fl no-pad
  308. Don't pad filenames so that they align in the output.
  309. .It Fl n , Fl Fl no-buffer
  310. Force stdout to be flushed after checking each file.
  311. This is only useful if checking a list of files.
  312. It is intended to be used by programs that want filetype output from a pipe.
  313. .It Fl p , Fl Fl preserve-date
  314. On systems that support
  315. .Xr utime 3
  316. or
  317. .Xr utimes 2 ,
  318. attempt to preserve the access time of files analyzed, to pretend that
  319. .Nm
  320. never read them.
  321. .It Fl P , Fl Fl parameter Ar name=value
  322. Set various parameter limits.
  323. .Bl -column "elf_phnum" "Default" "XXXXXXXXXXXXXXXXXXXXXXXXXXX" -offset indent
  324. .It Sy "Name" Ta Sy "Default" Ta Sy "Explanation"
  325. .It Li indir Ta 15 Ta recursion limit for indirect magic
  326. .It Li name Ta 30 Ta use count limit for name/use magic
  327. .It Li elf_notes Ta 256 Ta max ELF notes processed
  328. .It Li elf_phnum Ta 128 Ta max ELF program sections processed
  329. .It Li elf_shnum Ta 32768 Ta max ELF sections processed
  330. .It Li regex Ta 8192 Ta length limit for regex searches
  331. .It Li bytes Ta 1048576 Ta max number of bytes to read from file
  332. .El
  333. .It Fl r , Fl Fl raw
  334. Don't translate unprintable characters to \eooo.
  335. Normally
  336. .Nm
  337. translates unprintable characters to their octal representation.
  338. .It Fl s , Fl Fl special-files
  339. Normally,
  340. .Nm
  341. only attempts to read and determine the type of argument files which
  342. .Xr stat 2
  343. reports are ordinary files.
  344. This prevents problems, because reading special files may have peculiar
  345. consequences.
  346. Specifying the
  347. .Fl s
  348. option causes
  349. .Nm
  350. to also read argument files which are block or character special files.
  351. This is useful for determining the filesystem types of the data in raw
  352. disk partitions, which are block special files.
  353. This option also causes
  354. .Nm
  355. to disregard the file size as reported by
  356. .Xr stat 2
  357. since on some systems it reports a zero size for raw disk partitions.
  358. .It Fl S , Fl Fl no-sandbox
  359. On systems where libseccomp
  360. .Pa ( https://github.com/seccomp/libseccomp )
  361. is available, the
  362. .Fl S
  363. flag disables sandboxing which is enabled by default.
  364. This option is needed for file to execute external descompressing programs,
  365. i.e. when the
  366. .Fl z
  367. flag is specified and the built-in decompressors are not available.
  368. .It Fl v , Fl Fl version
  369. Print the version of the program and exit.
  370. .It Fl z , Fl Fl uncompress
  371. Try to look inside compressed files.
  372. .It Fl Z , Fl Fl uncompress-noreport
  373. Try to look inside compressed files, but report information about the contents
  374. only not the compression.
  375. .It Fl 0 , Fl Fl print0
  376. Output a null character
  377. .Sq \e0
  378. after the end of the filename.
  379. Nice to
  380. .Xr cut 1
  381. the output.
  382. This does not affect the separator, which is still printed.
  383. .Pp
  384. If this option is repeated more than once, then
  385. .Nm
  386. prints just the filename followed by a NUL followed by the description
  387. (or ERROR: text) followed by a second NUL for each entry.
  388. .It Fl -help
  389. Print a help message and exit.
  390. .El
  391. .Sh ENVIRONMENT
  392. The environment variable
  393. .Ev MAGIC
  394. can be used to set the default magic file name.
  395. If that variable is set, then
  396. .Nm
  397. will not attempt to open
  398. .Pa $HOME/.magic .
  399. .Nm
  400. adds
  401. .Dq Pa .mgc
  402. to the value of this variable as appropriate.
  403. The environment variable
  404. .Ev POSIXLY_CORRECT
  405. controls (on systems that support symbolic links), whether
  406. .Nm
  407. will attempt to follow symlinks or not.
  408. If set, then
  409. .Nm
  410. follows symlink, otherwise it does not.
  411. This is also controlled by the
  412. .Fl L
  413. and
  414. .Fl h
  415. options.
  416. .Sh FILES
  417. .Bl -tag -width __MAGIC__.mgc -compact
  418. .It Pa __MAGIC__.mgc
  419. Default compiled list of magic.
  420. .It Pa __MAGIC__
  421. Directory containing default magic files.
  422. .El
  423. .Sh EXIT STATUS
  424. .Nm
  425. will exit with
  426. .Dv 0
  427. if the operation was successful or
  428. .Dv >0
  429. if an error was encountered.
  430. The following errors cause diagnostic messages, but don't affect the program
  431. exit code (as POSIX requires), unless
  432. .Fl E
  433. is specified:
  434. .Bl -bullet -compact -offset indent
  435. .It
  436. A file cannot be found
  437. .It
  438. There is no permission to read a file
  439. .It
  440. The file type cannot be determined
  441. .El
  442. .Sh EXAMPLES
  443. .Bd -literal -offset indent
  444. $ file file.c file /dev/{wd0a,hda}
  445. file.c: C program text
  446. file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
  447. dynamically linked (uses shared libs), stripped
  448. /dev/wd0a: block special (0/0)
  449. /dev/hda: block special (3/0)
  450. $ file -s /dev/wd0{b,d}
  451. /dev/wd0b: data
  452. /dev/wd0d: x86 boot sector
  453. $ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
  454. /dev/hda: x86 boot sector
  455. /dev/hda1: Linux/i386 ext2 filesystem
  456. /dev/hda2: x86 boot sector
  457. /dev/hda3: x86 boot sector, extended partition table
  458. /dev/hda4: Linux/i386 ext2 filesystem
  459. /dev/hda5: Linux/i386 swap file
  460. /dev/hda6: Linux/i386 swap file
  461. /dev/hda7: Linux/i386 swap file
  462. /dev/hda8: Linux/i386 swap file
  463. /dev/hda9: empty
  464. /dev/hda10: empty
  465. $ file -i file.c file /dev/{wd0a,hda}
  466. file.c: text/x-c
  467. file: application/x-executable
  468. /dev/hda: application/x-not-regular-file
  469. /dev/wd0a: application/x-not-regular-file
  470. .Ed
  471. .Sh SEE ALSO
  472. .Xr hexdump 1 ,
  473. .Xr od 1 ,
  474. .Xr strings 1 ,
  475. .Xr magic __FSECTION__
  476. .Sh STANDARDS CONFORMANCE
  477. This program is believed to exceed the System V Interface Definition
  478. of FILE(CMD), as near as one can determine from the vague language
  479. contained therein.
  480. Its behavior is mostly compatible with the System V program of the same name.
  481. This version knows more magic, however, so it will produce
  482. different (albeit more accurate) output in many cases.
  483. .\" URL: http://www.opengroup.org/onlinepubs/009695399/utilities/file.html
  484. .Pp
  485. The one significant difference
  486. between this version and System V
  487. is that this version treats any white space
  488. as a delimiter, so that spaces in pattern strings must be escaped.
  489. For example,
  490. .Bd -literal -offset indent
  491. \*[Gt]10 string language impress\ (imPRESS data)
  492. .Ed
  493. .Pp
  494. in an existing magic file would have to be changed to
  495. .Bd -literal -offset indent
  496. \*[Gt]10 string language\e impress (imPRESS data)
  497. .Ed
  498. .Pp
  499. In addition, in this version, if a pattern string contains a backslash,
  500. it must be escaped.
  501. For example
  502. .Bd -literal -offset indent
  503. 0 string \ebegindata Andrew Toolkit document
  504. .Ed
  505. .Pp
  506. in an existing magic file would have to be changed to
  507. .Bd -literal -offset indent
  508. 0 string \e\ebegindata Andrew Toolkit document
  509. .Ed
  510. .Pp
  511. SunOS releases 3.2 and later from Sun Microsystems include a
  512. .Nm
  513. command derived from the System V one, but with some extensions.
  514. This version differs from Sun's only in minor ways.
  515. It includes the extension of the
  516. .Sq \*[Am]
  517. operator, used as,
  518. for example,
  519. .Bd -literal -offset indent
  520. \*[Gt]16 long\*[Am]0x7fffffff \*[Gt]0 not stripped
  521. .Ed
  522. .Sh SECURITY
  523. On systems where libseccomp
  524. .Pa ( https://github.com/seccomp/libseccomp )
  525. is available,
  526. .Nm
  527. is enforces limiting system calls to only the ones necessary for the
  528. operation of the program.
  529. This enforcement does not provide any security benefit when
  530. .Nm
  531. is asked to decompress input files running external programs with
  532. the
  533. .Fl z
  534. option.
  535. To enable execution of external decompressors, one needs to disable
  536. sandboxing using the
  537. .Fl S
  538. flag.
  539. .Sh MAGIC DIRECTORY
  540. The magic file entries have been collected from various sources,
  541. mainly USENET, and contributed by various authors.
  542. Christos Zoulas (address below) will collect additional
  543. or corrected magic file entries.
  544. A consolidation of magic file entries
  545. will be distributed periodically.
  546. .Pp
  547. The order of entries in the magic file is significant.
  548. Depending on what system you are using, the order that
  549. they are put together may be incorrect.
  550. If your old
  551. .Nm
  552. command uses a magic file,
  553. keep the old magic file around for comparison purposes
  554. (rename it to
  555. .Pa __MAGIC__.orig ) .
  556. .Sh HISTORY
  557. There has been a
  558. .Nm
  559. command in every
  560. .Dv UNIX since at least Research Version 4
  561. (man page dated November, 1973).
  562. The System V version introduced one significant major change:
  563. the external list of magic types.
  564. This slowed the program down slightly but made it a lot more flexible.
  565. .Pp
  566. This program, based on the System V version,
  567. was written by Ian Darwin
  568. .Aq ian@darwinsys.com
  569. without looking at anybody else's source code.
  570. .Pp
  571. John Gilmore revised the code extensively, making it better than
  572. the first version.
  573. Geoff Collyer found several inadequacies
  574. and provided some magic file entries.
  575. Contributions of the
  576. .Sq \*[Am]
  577. operator by Rob McMahon,
  578. .Aq cudcv@warwick.ac.uk ,
  579. 1989.
  580. .Pp
  581. Guy Harris,
  582. .Aq guy@netapp.com ,
  583. made many changes from 1993 to the present.
  584. .Pp
  585. Primary development and maintenance from 1990 to the present by
  586. Christos Zoulas
  587. .Aq christos@astron.com .
  588. .Pp
  589. Altered by Chris Lowth
  590. .Aq chris@lowth.com ,
  591. 2000: handle the
  592. .Fl i
  593. option to output mime type strings, using an alternative
  594. magic file and internal logic.
  595. .Pp
  596. Altered by Eric Fischer
  597. .Aq enf@pobox.com ,
  598. July, 2000,
  599. to identify character codes and attempt to identify the languages
  600. of non-ASCII files.
  601. .Pp
  602. Altered by Reuben Thomas
  603. .Aq rrt@sc3d.org ,
  604. 2007-2011, to improve MIME support, merge MIME and non-MIME magic,
  605. support directories as well as files of magic, apply many bug fixes,
  606. update and fix a lot of magic, improve the build system, improve the
  607. documentation, and rewrite the Python bindings in pure Python.
  608. .Pp
  609. The list of contributors to the
  610. .Sq magic
  611. directory (magic files)
  612. is too long to include here.
  613. You know who you are; thank you.
  614. Many contributors are listed in the source files.
  615. .Sh LEGAL NOTICE
  616. Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999.
  617. Covered by the standard Berkeley Software Distribution copyright; see the file
  618. COPYING in the source distribution.
  619. .Pp
  620. The files
  621. .Pa tar.h
  622. and
  623. .Pa is_tar.c
  624. were written by John Gilmore from his public-domain
  625. .Xr tar 1
  626. program, and are not covered by the above license.
  627. .Sh BUGS
  628. Please report bugs and send patches to the bug tracker at
  629. .Pa https://bugs.astron.com/
  630. or the mailing list at
  631. .Aq file@astron.com
  632. (visit
  633. .Pa https://mailman.astron.com/mailman/listinfo/file
  634. first to subscribe).
  635. .Sh TODO
  636. Fix output so that tests for MIME and APPLE flags are not needed all
  637. over the place, and actual output is only done in one place.
  638. This needs a design.
  639. Suggestion: push possible outputs on to a list, then pick the
  640. last-pushed (most specific, one hopes) value at the end, or
  641. use a default if the list is empty.
  642. This should not slow down evaluation.
  643. .Pp
  644. The handling of
  645. .Dv MAGIC_CONTINUE
  646. and printing \e012- between entries is clumsy and complicated; refactor
  647. and centralize.
  648. .Pp
  649. Some of the encoding logic is hard-coded in encoding.c and can be moved
  650. to the magic files if we had a !:charset annotation
  651. .Pp
  652. Continue to squash all magic bugs.
  653. See Debian BTS for a good source.
  654. .Pp
  655. Store arbitrarily long strings, for example for %s patterns, so that
  656. they can be printed out.
  657. Fixes Debian bug #271672.
  658. This can be done by allocating strings in a string pool, storing the
  659. string pool at the end of the magic file and converting all the string
  660. pointers to relative offsets from the string pool.
  661. .Pp
  662. Add syntax for relative offsets after current level (Debian bug #466037).
  663. .Pp
  664. Make file -ki work, i.e. give multiple MIME types.
  665. .Pp
  666. Add a zip library so we can peek inside Office2007 documents to
  667. print more details about their contents.
  668. .Pp
  669. Add an option to print URLs for the sources of the file descriptions.
  670. .Pp
  671. Combine script searches and add a way to map executable names to MIME
  672. types (e.g. have a magic value for !:mime which causes the resulting
  673. string to be looked up in a table).
  674. This would avoid adding the same magic repeatedly for each new
  675. hash-bang interpreter.
  676. .Pp
  677. When a file descriptor is available, we can skip and adjust the buffer
  678. instead of the hacky buffer management we do now.
  679. .Pp
  680. Fix
  681. .Dq name
  682. and
  683. .Dq use
  684. to check for consistency at compile time (duplicate
  685. .Dq name ,
  686. .Dq use
  687. pointing to undefined
  688. .Dq name
  689. ).
  690. Make
  691. .Dq name
  692. /
  693. .Dq use
  694. more efficient by keeping a sorted list of names.
  695. Special-case ^ to flip endianness in the parser so that it does not
  696. have to be escaped, and document it.
  697. .Pp
  698. If the offsets specified internally in the file exceed the buffer size
  699. (
  700. .Dv HOWMANY
  701. variable in file.h), then we don't seek to that offset, but we give up.
  702. It would be better if buffer managements was done when the file descriptor
  703. is available so move around the file.
  704. One must be careful though because this has performance (and thus security
  705. considerations).
  706. .Sh AVAILABILITY
  707. You can obtain the original author's latest version by anonymous FTP
  708. on
  709. .Pa ftp.astron.com
  710. in the directory
  711. .Pa /pub/file/file-X.YZ.tar.gz .