file.man 21 KB

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