Anders Johansson wrote:
On Friday 13 August 2004 04:42, Larry I Smith wrote:
Anders Johansson wrote:
On Thursday 12 August 2004 22:51, Larry I Smith wrote:
The new '/sbin/mkinitrd' script (rev 1.23 on my machine) has a *BUG* in the RegExp used to extract the "vga=..." value found in the GRUB 'menu.lst' file and the LILO 'lilo.conf' file. There is only one set of parens in the RegExp found at line 292 (inside the "for vga in..." block), but there should be two. Here's the 'diff' output (line-wrapped by the e-mailer of course); I've put carets (^) below the missing close and open parens that need to be added to make it work correctly again:
292c292 < -e 's/^.*[ \t]*vga [ \t]*=[\t]*\([0-9]\+\|0[xX][0-9a-fA-F]\+\).*$/\1/p'` ; do ---
-e 's/^.*[ \t]*vga
[ \t]*=[\t]*\([0-9]\+\)\|\(0[xX][0-9a-fA-F]\+\).*$/\1/p'` ; do ^^ ^^
No, this is wrong. The bug is there, but the fix is bad. If it works, it's by accident. Your regexp will match far too much, especially if there are other lines that use hexadecimal variables (hint: logical or now suddenly applies to the entire expression instead of just the parenthesis)
This is my first attempt at a fix
[ \t]*=[\t]*\(0[xX][0-9a-fA-F]\+\|[0-9]\+\).*$/\1/p'` ; do
or possibly
[ \t]*=[\t]*\([0-9][0-9][0-9]\|0[xX][0-9a-fA-F]\+\).*$/\1/p'` ; do
I disagree.
Remember the original is on one line; the emailer has split it onto two lines:
-e 's/^.*[ \t]*vga [ \t]*=[\t]*\([0-9]\+\)\|\(0[xX][0-9a-fA-F]\+\).*$/\1/p'`
The above should match "vga=" followed by a decimal number (e.g. vga=779), -or- "vga=" followed by a hex number (e.g. vga=0x31a).
It doesn't. It matches
"vga=" followed by one or more digits -or- any hexadecimal number on any line preceded by anything at all
Well, I guess my machine works differently than yours. If you copy the entire "handle splash screen" block to a standalone script and set 'splash="auto"' to mimic 'mkinitrd', and set 'vgascan="./test.txt"' instead of '/boot/grub/menu.lst', and add 'echo $vga' just before the 'case' statement, then given this './test.txt' file: vga=0x31a 0xffe vga=791 0xdda vga=123 vga=0xabc vga=nba 795 the script will echo: 0x31a 791 123 0xabc So, it only finds lines with "vga=" followed by a decimal or hexidecimal number. I think we're done here. This pattern (ignoring the spaces added for readability): regexp1 \(regexp2\) \| \(regexp3\) will match regexp1 followed by regexp2 -or- regexp1 followed by regexp3. The 'or' operator matches either of the 2 regexps enclosed in parens, but regexp1 must always be matched. Have a nice day. No more, please, that's enough..... Regards, Larry