[vim/vim] Fix three bugs with extracting lz4'd tar archives. (PR #19925)

8 views
Skip to first unread message

Aaron B

unread,
Apr 5, 2026, 8:33:11 PM (11 days ago) Apr 5
to vim/vim, Subscribed

The tar plugin allows users to extract files from tar archives that are compressed with lz4. But, tar#Extract() builds malformed extraction commands for lz4-compressed tar archives. This commit fixes three issues in that code. The first affects archives with a .tlz4 extension and the other two affect archives with .tar.lz4 extension (but one of these is symmetric to the issue that .tlz4 archives had).

(1) When trying to extract .tlz4 archives the command created by tar#Extract looked like this:

tar -I lz4pxf foo.tlz4 foo

This isn't right. It should be something like this:

tar -I lz4 -pxf foo.tlz4 foo

This was happening because tar.plugin is just substituting on the first - in "tar -pxf". This works fine if we just add a simple flag for extraction (eg, z for .tgz), but for lz4 we need to add "-I lz4".

I don't believe that there is an obvious good way to fix this without reworking the way the command is generated. Probably we should collect the command and flags separately and the flags should be stored in a set. Then put everything together into a string just before issuing it as an extraction command. Unfortunately, this might break things for users because they have access to tar_extractcmd.

This patch just makes the substitution a little bit more clever so that it does the right thing when substituting on a string like "tar -pxf".

(2) .tar.lz4 extractions had the same issue, which my patch fixes in the same way.

(3) .tar.lz4 extractions had another issue. There was a space missing in the command generated by tar#Extract. This meant that commands looked like this (notice the lack of space between the archive and output file names):

tar -I lz4pxf foo.tar.lz4foo

This patch just puts a space where it should be.

Finally, I should note that ChatGPT 5.4 initially identified this issue in the code and generated the test cases. I reviewed the test cases, wrote the patch, and actually ran vim against the tests (both with and without the patch).


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19925

Commit Summary

  • 327739f Fix three bugs with extracting lz4'd tar archives.

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925@github.com>

Aaron B

unread,
Apr 5, 2026, 9:16:44 PM (11 days ago) Apr 5
to vim/vim, Subscribed
7188ce06 left a comment (vim/vim#19925)

The two tests are failing on non-Linux systems. tar is being supplied with options on the assumption that it is GNU tar compatible. This patch doesn't introduce that assumption, it was already in the code. I see two ways to move forward:

  1. Just deactivate the tests outside of Linux. This might be fine because these tests would also fail for a vim on non-Linux without my patch.
  2. Replacing the "-I" flag with "--use-compress-program" might do the right thing on all of the systems.

I'm open to suggestions.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4189896112@github.com>

Aaron B

unread,
Apr 5, 2026, 9:23:48 PM (11 days ago) Apr 5
to vim/vim, Push

@7188ce06 pushed 1 commit.

  • d783af1 Try --use-compress-program instead of -I.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/before/327739f4e2da8a9dde0f6f7f5ecd4fe65393ad90/after/d783af1d9670aa28a569bb5087eefb91944759c5@github.com>

Aaron B

unread,
Apr 5, 2026, 9:42:56 PM (11 days ago) Apr 5
to vim/vim, Push

@7188ce06 pushed 1 commit.

  • 0924637 --use-compress-program didn't help on FreeBSD or OS X. Just disable the tests for them.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/before/d783af1d9670aa28a569bb5087eefb91944759c5/after/0924637f7c86a8cdf0488846f2fa2c8761d3696c@github.com>

Aaron B

unread,
Apr 5, 2026, 10:00:16 PM (11 days ago) Apr 5
to vim/vim, Subscribed
7188ce06 left a comment (vim/vim#19925)

"--use-compress-program=lz4" did not work for FreeBSD and OS X. d783af1


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4189977391@github.com>

Christian Brabandt

unread,
Apr 6, 2026, 4:21:12 AM (11 days ago) Apr 6
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19925)

If possible we should try to be portable, meaning we should aim for --use-compress-program if this is portable accross different Unix flavors. If this doesn't work, let's just disable the test on non-Linux systems


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4191103420@github.com>

Aaron B

unread,
Apr 6, 2026, 4:34:37 AM (11 days ago) Apr 6
to vim/vim, Subscribed
7188ce06 left a comment (vim/vim#19925)

@chrisbra "--use-compress-program=lz4" did not work as you can see in the tests for the second commit on this branch. I'll setup a FreeBSD server and see what's going on, but I don't have access to an OS X system.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4191159916@github.com>

Aaron B

unread,
Apr 6, 2026, 5:22:13 AM (11 days ago) Apr 6
to vim/vim, Push

@7188ce06 pushed 1 commit.

  • 514d1cb Only make the lz4 sub on Linux because FreeBSD's tar automatically handles lz4.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/before/0924637f7c86a8cdf0488846f2fa2c8761d3696c/after/514d1cb83f7d8ab10699645fd8a0ea153b347a10@github.com>

Aaron B

unread,
Apr 6, 2026, 5:24:11 AM (11 days ago) Apr 6
to vim/vim, Push

@7188ce06 pushed 1 commit.

  • 3e88797 Only make the lz4 sub on Linux because FreeBSD's tar automatically handles lz4.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/before/514d1cb83f7d8ab10699645fd8a0ea153b347a10/after/3e8879784ba24c61add7d3714dc5b5dadee253aa@github.com>

Aaron B

unread,
Apr 6, 2026, 6:01:25 AM (11 days ago) Apr 6
to vim/vim, Subscribed
7188ce06 left a comment (vim/vim#19925)

@chrisbra FreeBSD man page for tar says "Note that this tar implementation recognizes lz4 compression automatically when reading archives." So this new patch only does the substitution on Linux and then let's FreeBSD's (and OS X's?) tar just use the automatic lz4 detection feature.

What do you think is best?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4191540406@github.com>

Christian Brabandt

unread,
Apr 6, 2026, 6:43:10 AM (11 days ago) Apr 6
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19925)

That sounds reasonable. Thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4191750926@github.com>

Christian Brabandt

unread,
Apr 6, 2026, 8:49:35 AM (11 days ago) Apr 6
to vim/vim, Subscribed

Closed #19925 via 78954f8.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/issue_event/24223974245@github.com>

Vladimír Marek

unread,
Apr 15, 2026, 3:43:46 PM (2 days ago) Apr 15
to vim/vim, Subscribed
vlmarek left a comment (vim/vim#19925)

Hi guys, this change broke Solaris tests. My understanding is that there are four flavors of tar with regards to lz4.

a) Native support (as for example FreeBSD). tar xf archive.tar.lz4
b) GNU which has ... -I lz4 ...
c) GNU which has ... --use-compress-program lz4 ...
d) tar which has none of those.

On Solaris /usr/bin/tar is d), /usr/gnu/bin/tar is b)+c). I'll be patching the file by

call system("lz4 --decompress --stdout -- ".shellescape(tarball)." | ".extractcmd." - ".shellescape(fname))

That should work in all cases. But is it the best solution? I do not know, sorry :)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4254957087@github.com>

Christian Brabandt

unread,
Apr 15, 2026, 4:12:37 PM (2 days ago) Apr 15
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19925)

Sorry about that. can you submit a PR for this?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4255135895@github.com>

Aaron B

unread,
Apr 15, 2026, 9:19:44 PM (2 days ago) Apr 15
to vim/vim, Subscribed
7188ce06 left a comment (vim/vim#19925)

@chrisbra @vlmarek Sorry, I didn't do enough research.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4256715247@github.com>

Vladimír Marek

unread,
Apr 16, 2026, 3:07:14 AM (23 hours ago) Apr 16
to vim/vim, Subscribed
vlmarek left a comment (vim/vim#19925)

@chrisbra No need to be sorry! On the other way I am very grateful that you spend time on vim even on such minor things! This is hard task to do as there is unlimited number of OS variants behaving differently. I'm more than happy to create PR (it's trivial after all), question is how it should behave?

  • I can make vim always use lz4 --decompress --stdout -- | tar ...
  • I can keep vim using ... -I lz4 - ... on Linux as it is now and for any non-linux system use lz4 --decompress --stdout -- | tar ... (that's my current patch for solaris build)
  • I can keep vim using ... -I lz4 - ... on Linux as it is now and make Solaris use lz4 --decompress --stdout -- | tar ... and on any other system expect tar to handle .tar.lz4 directly on it's own (as it does now).
    Personally I would use lz4 --decompress --stdout -- | tar ... everywhere, but this is matter of personal preference more than anything else.

@7188ce06 yes. Opening a tar.lz4 file by vim 9.2.209 is using

(lz4 --decompress --stdout -- '/builds/vmarek/merge/make-rules.tar.lz4' | /usr/sfw/bin/gtar -tf - )>/tmp/vBZOFTd/0 2>&1

(lz4 --decompress --stdout -- '/builds/vmarek/merge/make-rules.tar.lz4' | /usr/sfw/bin/gtar -pxf - -- 'make-rules/x11-component.mk')>/tmp/vBZOFTd/2 2>&1

I did verify with older vim 9.1.1591 and behaves the same too.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19925/c4258051334@github.com>

Reply all
Reply to author
Forward
0 new messages