ouch-org / ouch

Painless compression and decompression in the terminal
https://crates.io/crates/ouch
Other
2.18k stars 75 forks source link

Compressing a `.tar` file causes (maybe) undesirable double-wrapping #668

Open cyqsimon opened 3 months ago

cyqsimon commented 3 months ago

Version

0.5.1

Description

When trying to compress a file that is already a .tar file using a command like so: ouch c foo.tar foo.tar.zst, the result is a foo.tar.zst that contains a foo.tar, which contains the contents. This behaviour is not customisable and possibly undesirable - the user may want (as I did) a foo.tar.zst that directly contains the contents of foo.tar.

I think it would be better to prompt the user and/or add a flag to allow the user to specify what to do. The prompt would trigger when all three conditions are met:

  1. There is only one input file.
  2. The input file has extension .tar.
  3. The selected output format is *.tar.*.

I would like to submit a PR for this if time allows, but it may not. If anyone wants to claim this please go ahead.