FS#25546 - /arch/setup fails on archlinux-2011.08.12-core-x86_64

Attached to Project: Release Engineering
Opened by Martin Schmidt (Blind) - Saturday, 13 August 2011, 03:47 GMT
Last edited by Dieter Plaetinck (Dieter_be) - Saturday, 13 August 2011, 20:18 GMT
Task Type Bug Report
Category AIF
Status Closed
Assigned To No-one
Architecture x86_64
Severity Critical
Priority Normal
Reported Version testbuild (specify!)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Trying out releng.archlinux.org/isos/archlinux-2011.08.12-core-x86_64

When trying to run /arch/setup, the script fails in
/usr/.../core/libs/lib-blockdevices-filesystems.sh
with a syntax error on line 300.

The /arch/setup script bails out with an error about sourcing the above file.

It seems the develop branch github file is the one that fails.
This task depends upon

Closed by  Dieter Plaetinck (Dieter_be)
Saturday, 13 August 2011, 20:18 GMT
Reason for closing:  Fixed
Additional comments about closing:  fixed since 2011.08.13
Comment by Dieter Plaetinck (Dieter_be) - Saturday, 13 August 2011, 12:10 GMT
Turns out this is not fixed.
easily reproducable on my home system:

$ shopt -s extglob; for devpath in /dev/mapper/!(arch_*); do echo $devpath; done; shopt -u extglob
/dev/mapper/control
/dev/mapper/cryptpool-home
/dev/mapper/cryptpoolhost
/dev/mapper/cryptpool-root
/dev/mapper/cryptpool-swap

$ cat test.sh
#!/bin/bash
shopt -s extglob; for devpath in /dev/mapper/!(arch_*); do echo $devpath; done; shopt -u extglob
$ ./test.sh
./test.sh: line 2: syntax error near unexpected token `('
./test.sh: line 2: `shopt -s extglob; for devpath in /dev/mapper/!(arch_*); do echo $devpath; done; shopt -u extglob'


WTF?
$ bash --version
GNU bash, version 4.2.10(2)-release (i686-pc-linux-gnu)
(..)
Comment by Martin Schmidt (Blind) - Saturday, 13 August 2011, 16:37 GMT
I don't know if this helps, but this is what I am getting in a functional Arch install, on a terminal:

> shopt -s extglob; for devpath in /dev/mapper/!(arch_*); do echo $devpath; done; shopt -u extglob
bash: !: event not found

and the same with setting nullglob (like in the script):

> shopt -s nullglob; shopt -s extglob; for devpath in /dev/mapper/!(arch_*); do echo $devpath; done; shopt -u extglob; shopt -u nullglob
bash: !: event not found

> bash --version
GNU bash, version 4.2.10(2)-release (x86_64-unknown-linux-gnu)
Comment by Gerardo Exequiel Pozzi (djgera) - Saturday, 13 August 2011, 16:47 GMT
Do not inline ;) Changes does not take any effect on the same line.
Comment by Dave Reisner (falconindy) - Saturday, 13 August 2011, 16:51 GMT
The issue there is in parsing the singular command without breaking in between. The Bash parser picks up the ! and attempts to perform history expansion via readline because extglob isn't technically yet enabled. Even with history expansion disabled, this still fails. It must be done as separate invocations.

shopt -s extglob
printf '%s\n' /dev/mapper/!(arch_*)
shopt -u extglob

The root of the problem is that enabling extglob from within the function does not work. Any and all shopts should be declared at the top of the file that they're used in. A short proof of isolation of this problem...

#!/bin/bash

foo() {
shopt -s extglob
printf '%s\n' /dev/mapper/!(arch_*)
}

foo

------------
foo: line 5: syntax error near unexpected token `('
foo: line 5: ` printf '%s\n' /dev/mapper/!(arch_*)'
Comment by Martin Schmidt (Blind) - Saturday, 13 August 2011, 17:05 GMT
He, you know what you are doing :D
So, Dieterbe had that option already turned on in his proof above there, I gather.

Comment by Gerardo Exequiel Pozzi (djgera) - Saturday, 13 August 2011, 17:16 GMT
shopt extglob works on functions but, you need to do some hack-

First set extglob abpve function, and unset at end. In this way bash can parse the function without any issue.
Second set extglob before the command, so extglob is enabled during running flow.

shopt -s extglob
functiom() {

shopt -s extglob
command-that-needs-extglob
shopt -u extglob

}
shopt -u extglob
Comment by Dave Reisner (falconindy) - Saturday, 13 August 2011, 17:17 GMT
if you set extglob outside the function, its not needed inside.

I'll reiterate: Any and all shopts should be declared at the top of the file that they're used in.
Comment by Gerardo Exequiel Pozzi (djgera) - Saturday, 13 August 2011, 17:35 GMT
But Dieter does not want to set extglob for all script. In this way I set/_unset_ extglob for parse step, then set and unset for runnung step.

Try this:
---
shopt -s extglob
foo() {
shopt -s extglob
printf '%s\n' /dev/mapper/!(arch_*)
}
shopt -u extglob

foo
----
Comment by Dieter Plaetinck (Dieter_be) - Saturday, 13 August 2011, 17:37 GMT
I generally try to avoid setting non-default behavior globally, and only try to use it for the specific part where it's needed. However in this case that's not possible, at least not in an elegant way, and extglob is not harmful to any other code, so I pushed a fix to git already that sets the option globally. The thing to do now is wait for a new testbuild and check whether the error is gone.

Loading...