file.man 21 KB

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