Bug 121993 - rpm cannot handle filenames with square brackets in them
rpm cannot handle filenames with square brackets in them
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: rpm (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
Mike McLean
Depends On:
  Show dependency treegraph
Reported: 2004-04-29 12:28 EDT by Ken Snider
Modified: 2007-11-30 17:07 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-05-04 12:19:29 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Ken Snider 2004-04-29 12:28:14 EDT
Description of problem:
Passing a filename with square brackets in it to RPM will result in
RPM being unable to find the filem even though said characters are
valid in a filename.


[root@<server> ksnider]# rpm -ihv 'libusb-0[1].1.6-3.i386.rpm'
error: File not found by glob: libusb-0[1].1.6-3.i386.rpm

Version-Release number of selected component:

How reproducible:

Steps to Reproduce:
1. Add square brackets to a filename (libusb-0[1].1.6-3.i386.rpm)
2. Ask RPM to perform an operation on it (-i and -U were tried)
3. Witness the 'File not found by glob' error message.
Comment 1 Jeremy Katz 2004-04-29 18:16:25 EDT
This isn't a bug in RPM.  bash is seeing the existence of the file and
doing globbing on the command line before passing the args to rpm.
Comment 2 Ken Snider 2004-04-29 18:32:39 EDT
*Really now*..

[root@<host> ksnider]# echo 'libusb-0[1].1.6-3.i386.rpm'
[root@<host> ksnider]# less 'libusb-0[1].1.6-3.i386.rpm'
"libusb-0[1].1.6-3.i386.rpm" may be a binary file.  See it anyway?
[root@<host> ksnider]# grep usb 'libusb-0[1].1.6-3.i386.rpm'
Binary file libusb-0[1].1.6-3.i386.rpm matches
[root@<host> ksnider]# ls -l 'libusb-0[1].1.6-3.i386.rpm'
-rw-r--r--    1 root     root        11382 Apr 29 15:48

Amazing how every other program can *perfectly interpret* what is
being passed to it as an argument, hm?

See, bash has this neat little feature called "Shell Grammar". This
grammar allows you to modify the arguments given to a file such that
the arguments aren't otherwise manipulated by the shell. The Oreilly
bash book can probably explain this is more detail, but I'll do you
the favour of including an excerpt from the man page:

"Enclosing  characters  in  single quotes preserves the literal value
of each character within the quotes.  A single quote may not occur
between single quotes, even when preceded by a backslash."

In other words, no. The shell is *not* seeing the existence of
anything and doing anything to it. That was the purpose of the single
quotes surrounding the text - to remove any expansion performed by the

No, I'm afraid this really is a bug in RPM. Sorry.
Comment 3 Jeff Johnson 2004-05-04 11:19:06 EDT
Putting square brackets in file names is asking for trouble.
Have fun!
Comment 4 Ken Snider 2004-05-04 11:38:12 EDT

You understand that this behavior is both part of the POSIX
specification, and REQUIRED for LSB compliance, yes?

Specifically Chapter 23 of LSB 1.3 indicates that "Utilities that
perform filename globbing (also known as Pattern Matching Notation)
shall do it as specified in the Single UNIX Specification".

Section 2.13 of said Specification (Pattern Matching Notation)
indicates that a single bracket character should only be treated as a
special character if unescaped.

This is an LSB-compliance-affecting BUG in RPM. More importantly, as
I've shown, RPM's behaviour is INCONSISTENT with other system
utilities which *do* follow POSIX/LSB specifications in handling files
of this type.
Comment 5 Jeff Johnson 2004-05-04 12:19:29 EDT

Note You need to log in before you can comment on or make changes to this bug.