[Bug 2051735] Re: fails to use `file` to determine file type as claimed

Joe Strout 2051735 at bugs.launchpad.net
Tue Jan 30 21:53:29 UTC 2024


I believe the problem is that Perl is trying to execute the 'command'
intrinsic of sh, but on modern Ubuntu, sh has been replaced with dash
(/usr/bin/sh is just a symlink to /usr/bin/dash).  It appears that dash
does include a "command" intrinsic, but maybe it behaves differently,
because I can't get it to work when invoked from Perl at all.

My suggested fix is to explicitly run the command intrinsic from bash
instead, by changing line 301 to:

```
    if (`bash -c 'command -v file'`) {
```

In my testing, this fixes the problem.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to mailcap in Ubuntu.
https://bugs.launchpad.net/bugs/2051735

Title:
  fails to use `file` to determine file type as claimed

Status in mailcap package in Ubuntu:
  New

Bug description:
  The man page for run-mailcap claims " If no mime-type is found, a last attempt will be done by running
  the file command, if available."  But this does not actually work.  Example:

  1. Find or make a plain text file called LICENSE.
  2. Use the `file` command in the same way as run-mailcap to check its type:
  ```
     file -b --mime-type -e tokens -L -z LICENSE
  ```
  It reports "text/plain".
  3. Now try `run-mailcap LICENSE` (or any equivalent, such as `edit LICENSE`).  I get:
  Warning: unknown mime-type for "LICENSE" -- using "application/octet-stream"
  Error: no "view" mailcap rules found for type "application/octet-stream"

  If you comment out the `if` and `}` lines in /usr/bin/run-mailcap
  (lines 301 and 306), and try the run-mailcap command again, it works.

  So, somehow the test for whether file is available is failing within
  the script, even though `command -v file` works just fine on the
  command line.

  Description:	Ubuntu 22.04.3 LTS
  Release:	22.04

  mailcap:
    Installed: 3.70+nmu1ubuntu1
    Candidate: 3.70+nmu1ubuntu1
    Version table:
   *** 3.70+nmu1ubuntu1 500
          500 http://us-east1.gce.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
          100 /var/lib/dpkg/status

  ProblemType: Bug
  DistroRelease: Ubuntu 22.04
  Package: mailcap 3.70+nmu1ubuntu1
  ProcVersionSignature: Ubuntu 6.2.0-1019.21~22.04.1-gcp 6.2.16
  Uname: Linux 6.2.0-1019-gcp x86_64
  ApportVersion: 2.20.11-0ubuntu82.5
  Architecture: amd64
  CasperMD5CheckResult: unknown
  CloudArchitecture: x86_64
  CloudID: gce
  CloudName: gce
  CloudPlatform: gce
  CloudRegion: us-east1
  CloudSubPlatform: metadata (http://metadata.google.internal/computeMetadata/v1/)
  Date: Tue Jan 30 21:24:13 2024
  PackageArchitecture: all
  SourcePackage: mailcap
  UpgradeStatus: Upgraded to jammy on 2024-01-04 (26 days ago)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mailcap/+bug/2051735/+subscriptions




More information about the foundations-bugs mailing list