View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 14 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Mon Feb 28, 2005 8:48 pm 
Offline
Joined: Mon Feb 28, 2005 8:43 pm
Posts: 10
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?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 8:50 pm 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
No, I just release it and hope for the best...

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
PostPosted: Mon Feb 28, 2005 9:09 pm 
Offline
Joined: Mon Feb 21, 2005 11:56 am
Posts: 38
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.


Top
 Profile  
 
PostPosted: Mon Feb 28, 2005 10:28 pm 
Offline
Joined: Mon Feb 28, 2005 8:43 pm
Posts: 10
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 11:48 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 8:47 am 
Offline
Joined: Mon Feb 28, 2005 8:43 pm
Posts: 10
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 9:59 am 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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. ;-) Based on that expertise I'm telling you that it not only looks fine to me but did the right think when I cut it out and tested it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 11:29 am 
Offline
Joined: Mon Jun 21, 2004 5:28 am
Posts: 700
Location: Germany
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? :D

Allen

_________________
ASUS AT3N7A-I (Atom 330)
TBS 8922 PCI (DVB-S2)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 7:23 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 8:14 pm 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 10:34 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 02, 2005 1:32 am 
Offline
Joined: Fri May 21, 2004 11:55 pm
Posts: 1206
Location: Silicon Valley, CA
No... Stop... No... My MIND.... It's... EXPANDING!!!

OWWWW!! It HURTS!!!

_________________
Do you code to live, or live to code?
Search LinHES forum through Google


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 02, 2005 1:57 am 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
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? :shock:

P.S I like the awk tip though. :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 02, 2005 1:58 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
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. ;-)


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu