Red Hat Bugzilla – Bug 121993
rpm cannot handle filenames with square brackets in them
Last modified: 2007-11-30 17:07:01 EST
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.6-3.i386.rpm'
error: File not found by glob: libusb-0.1.6-3.i386.rpm
Version-Release number of selected component:
Steps to Reproduce:
1. Add square brackets to a filename (libusb-0.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.
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.
[root@<host> ksnider]# echo 'libusb-0.1.6-3.i386.rpm'
[root@<host> ksnider]# less 'libusb-0.1.6-3.i386.rpm'
"libusb-0.1.6-3.i386.rpm" may be a binary file. See it anyway?
[root@<host> ksnider]# grep usb 'libusb-0.1.6-3.i386.rpm'
Binary file libusb-0.1.6-3.i386.rpm matches
[root@<host> ksnider]# ls -l 'libusb-0.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.
Putting square brackets in file names is asking for trouble.
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.