Skip to content

zipgrep fails to search files named "-e" or "-n" (among others)

Task Info (Flyspray)
Opened By Lex (lexbailey)
Task ID 76905
Type Bug Report
Project Arch Linux
Category Packages: Extra
Version None
OS All
Opened 2022-12-21 17:41:36 UTC
Status Assigned
Assignee Lukas Fleischer (lfleischer)
Assignee Jonas Witschel (diabonas)

Details

Description:

zipgrep fails to search files with specific file names inside zip files. This issue is peculiar to systems where /bin/sh is bash, as is (afaict) the default for Arch. (For example, this works fine on debian where /bin/sh is dash by default)

any zip file that contains files with the following names will show this bug: -e -n -E -en ...etc

In summary: if the file name starts with a dash and is followed only by characters in [neE] then this problem occurs.

zipgrep tries to process each file name by echoing it into another command, but bash's echo interprets files with names like these as if they are options to echo and thus does not echo them.

A fix that works for me is to swap the echo for a printf:

72c72 < i=` echo "$i" | \

i=` printf '%s' "$i" | \

However, given that this works fine on not-bash shells I suspect that the upstream response to a patch like this would be "just use dash or similar". This is of course a valid option, to make this package depend on dash and then change the #! line

Additional info:

  • package version: 6.0-19

Steps to reproduce:

Consider the following bash session...

$ echo bar > -e $ zip e.zip -- -e adding: -e (stored 0%) $ zipgrep bar e.zip caution: filename not matched:
$

I would not expect to see "caution: filename not matched:" instead, I would expect "-e: bar"

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information