LinHES Forums http://forums.linhes.org/ |
|
Bug in auto install for ISO (KnoppMythR5A10.iso) http://forums.linhes.org/viewtopic.php?f=1&t=3740 |
Page 1 of 1 |
Author: | brill [ Mon Feb 28, 2005 8:48 pm ] |
Post subject: | Bug in auto install for ISO (KnoppMythR5A10.iso) |
The KnoppMythR5A10.iso has a but in /usr/local/bin/KnoppMyth-auto on line:608 There is an extra "$" inside the [] and in front of the SIZE var. Remove that and it should be fine. Has no one doing development actually run the installer all the way through? |
Author: | cesman [ Mon Feb 28, 2005 8:50 pm ] |
Post subject: | |
No, I just release it and hope for the best... |
Author: | mfl2k3 [ Mon Feb 28, 2005 9:09 pm ] |
Post subject: | Re: Bug in auto install for ISO (KnoppMythR5A10.iso) |
brill wrote: The KnoppMythR5A10.iso has a but in /usr/local/bin/KnoppMyth-auto on line:608 I am sure if there was a but in there someone would have smelt it! Are you sure you are not mistaken? brill wrote: There is an extra "$" inside the [] and in front of the SIZE var. Remove that and it should be fine. Hey I could use an extra $ or 2! brill wrote: Has no one doing development actually run the installer all the way through?
See had you left out this part your post would have been informative and helpful. With this part you just come across bad. |
Author: | brill [ Mon Feb 28, 2005 10:28 pm ] |
Post subject: | Re: Bug in auto install for ISO (KnoppMythR5A10.iso) |
mfl2k3 wrote: brill wrote: The KnoppMythR5A10.iso has a but in /usr/local/bin/KnoppMyth-auto on line:608 I am sure if there was a but in there someone would have smelt it! Are you sure you are not mistaken? Well I'm not an expert in shell scripts, but I'm faily sure its a problem. The SIZE var is set in the same scope and I think it's not supposed to be referenced with a $... ? mfl2k3 wrote: brill wrote: Has no one doing development actually run the installer all the way through? See had you left out this part your post would have been informative and helpful. With this part you just come across bad. not my intention to be rude, just pointing out that a test is in order. There is a note at: http://knoppmythwiki.homelinux.org/inde ... ythInstall that talks about the error and it is the line I'm speaking of, so I could be wrong about it. Anyway, it certainly warrents a look from someone who is good with shell scripts. FYI - I copied the KnoppMyth-auto script fromt he ISO to my /ramdrive dir and edited it; it then allowed me past that part of the script. |
Author: | tjc [ Mon Feb 28, 2005 11:48 pm ] |
Post subject: | |
I looked. You're wrong. A quick test would have shown you that $[ EXPRESSION ] is equilvalent to `expr EXPRESION` if you're more familiar with that idiom for doing calculations.. Code: root@black:/var/log# echo $[33 / 3]
11 root@black:/var/log# echo `expr 33 / 3` 11 The line in question is computing the disk size in (decimal) megabytes. 'Kay? |
Author: | brill [ Tue Mar 01, 2005 8:47 am ] |
Post subject: | |
tjc wrote: I looked. You're wrong. A quick test would have shown you that $[ EXPRESSION ] is equilvalent to `expr EXPRESION` if you're more familiar with that idiom for doing calculations..
Code: root@black:/var/log# echo $[33 / 3] 11 root@black:/var/log# echo `expr 33 / 3` 11 The line in question is computing the disk size in (decimal) megabytes. 'Kay? But thats that I'm saying! Sould there be a extra "$" as in the lines below when X is in the same scope: X=33; echo $[$X / 3]; rather than: X=33; echo $[X / 3]; I wasn't trying to bring attention to the "[]" at all. WHen I di a quick test in the shell, both of the above work, however when done in the script the $SIZE var doesn't seem to exist and the expression becomes: echo $[ / 3] in fact if you execute that in your shell, you'll see that you get the same error output by the script... Which is strange because the SIZE var is set in the line just before the call. |
Author: | tjc [ Tue Mar 01, 2005 9:59 am ] |
Post subject: | |
From memory the code in question is roughly this: Code: DISK_SIZE=$[ $SIZE / 1000000 ]
The inner $ causes variable expansion, the outer one causes calculation expansion. I almost pasted the original in last night and did a full tutorial walk through picking it apart step by step (including the fact that using both grep and awk is silly since awk could do the pattern matching too), but figured it might be wasted effort.. I write lots of shell script these days, and code review more, so I have some expertise. ![]() |
Author: | alien [ Tue Mar 01, 2005 11:29 am ] |
Post subject: | |
I'm not much of a bash expert, but I am pretty handly at trial and error. It seems the problem is that $SIZE is undefined. If this happens, than removing the $ fixes the error without changing the functionality (strangely enough). Code: $ X=33; echo $[$X / 3];
11 $ echo $[X / 3]; 11 $ echo $[$Y / 3]; bash: / 3: syntax error: operand expected (error token is "/ 3") $ echo $[Y / 3]; 0 I don't think this is a big issue as I don't think a zero size disk is going to install very well. Who let this unintialized variable through code inspection anyway? ![]() Allen |
Author: | tjc [ Tue Mar 01, 2005 7:23 pm ] |
Post subject: | |
I won't even go into how many ways that is NOT a fix. Here is the exact code in question: Code: SIZE=$(fdisk -l $DEV 2>&1 | grep "^Disk ${DEV}: " | awk '{print $5}') DISK_SIZE=$[$SIZE / 1000000] SIZE is set on the immediately preceding line. Presumbaly DEV comes from a list of know devices and thus should always return a result. Checking that it got a result and providing an error message couldn't hurt, but really shouldn't be necessary unless you've done something silly with your hardware and /dev/hda doesn't have a size because it an optical disk. BTW: Code: awk '$0 ~ "^Disk '${DEV}': " {print $5}' would simplify the first pipeline above.
|
Author: | Greg Frost [ Tue Mar 01, 2005 8:14 pm ] |
Post subject: | |
everyone knows how grep works (well almost) but the same can't be said for awk, so whilst your change has less characters in it, I find it less intuitive than the original. |
Author: | tjc [ Tue Mar 01, 2005 10:34 pm ] |
Post subject: | |
Consider it a mind expanding exercise. In this case it doesn't matter since the enclosing function isn't called in a loop, but running two commands rather than three can make a difference in performance, and using awk can simplify stuff that's much harder and messier in shell. |
Author: | Liv2Cod [ Wed Mar 02, 2005 1:32 am ] |
Post subject: | |
No... Stop... No... My MIND.... It's... EXPANDING!!! OWWWW!! It HURTS!!! |
Author: | Greg Frost [ Wed Mar 02, 2005 1:57 am ] |
Post subject: | |
Thanks for expanding my mind but I still like the first option better. It's not like in this case performance is even remotely an issue, and the first option just screams at you saying I'm searching for the line that has the disk we are looking for and then grabbing the fifth column from that line (which from the context I can see is the disk size). Now, anyone have tips on how I can fit this expanded mind back in my head? ![]() P.S I like the awk tip though. ![]() |
Author: | tjc [ Wed Mar 02, 2005 1:58 pm ] |
Post subject: | |
There is no way to fit your expanded mind back in your old skull. I'm afraid you're stuck with the Mojo Jojo exposed brain look now. ![]() It could be worse, I almost posted my quick and dirty pgrep/pkill implementation (AIX doesn't have them) using only ps, awk and of course kill. It only has two rules and one of them is an END just so it exits with the right return code. ![]() |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |