Subject: Re: bug#22433: mkdir bug (?)

From: Eric Blake <[email-masked]>
Date: Fri, 22 Jan 2016 09:52:32 -0700

tag 22433 notabug
thanks

On 01/22/2016 05:52 AM, [email-masked] wrote:
> The following command:
> (cd ${IMAGE_MODIFIED_ROOTFS}; mkdir -p opt/chloride/{bin,etc,var,archive};)
> 
> Created the following:

Thanks for the report.  Next time, please copy and paste text into your
email, rather than attaching an image, as it not only wastes bandwidth,
but it is also harder to reply to a screenshot.

Transcription of your image:

> total 12
> drwxrwxr-x 3 user user 4096 Jan 22 13:46 .
> drwxrwxr-x 3 user user 4096 Jan 22 13:46 ..
> drwxrwxr-x 2 user user 4096 Jan 22 13:46 {bin,etc,var,archive}
> user@user-virtual-machine:/tmp/ghmi/opt/chloride$

But I see no bug there - you asked for a file name with braces, and got one.

Oh, were you expecting brace expansion to happen?  Brace expansion is a
feature of some shells (such as bash), but is not required by POSIX and
is therefore not universal to all shells (such as dash).  I suspect you
normally use bash, but ran your command on a system where /bin/sh is dash.

To find out whether you are using a shell that does brace expansion, try:

echo {a,b}

If the result is "{a,b}", then you will get the same behavior for your
mkdir command.  If the result is "a b", then you will get four
directories due to brace expansion.  But remember that it is your shell,
not mkdir, that does brace expansion prior to mkdir ever seeing its
arguments.

As such, I'm closing this as not a bug, but feel free to add further
comments to this thread.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org