Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: functions5.lua, function getbootparam()< Next Oldest | Next Newest >
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: July 16 2007,00:00 QUOTE

function getbootparam uses io.input("/proc/cmdline") to read the boot parameters from /proc/cmdline
Should there be an io.input() with no argument to return the default input to stdin?

I assume there is no issue with DSL in the way it uses functions5.lua, but i was wondering mostly if "standard" use of the io.input function would say it should be reset to stdin


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: July 16 2007,00:40 QUOTE

Yes!  Good observation! Lazy me. My bad.
Although, upon program termination it is reset. But still it much better to reset it when done with task at hand.
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: July 16 2007,04:01 QUOTE

I was guessing there probably wasn't a problem when used in the way DSL uses it. I was mainly asking in order to be sure to present the most reliable and universal way to use io.input to other users.

Thank you.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: July 17 2007,01:43 QUOTE

I don't want to be a pain, but I think there might be a bug (sort of) in this very same function.

Here's what I assume is the intended behavior of the function:
If you have a boot option foo=bar, you use getbootparam("foo=") and it will return "bar".
If you have the boot option "foo", you use getbootparam("foo") and it will return foo. Maybe I'm wrong about this second one, but it seems to (sort of) work this way.

However, depending on how you have written your boot line, it may not return what you expect.  If you have a boot option "foobar=bar" or "bar=foo" or "foobar", and you use getbootparam("foo"), it will return "foo".

Of course the more I think about it, the more I wonder if it is actually not intended to be used without "=" as part of the function parameter. In that case, I apologize for bringing this up. If it wasn't intended to be used this way, I think it *could* possibly be fixed to do so, and then you could use the same function to grab either "foo" or "foo=bar" type of boot parameters.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: July 20 2007,07:03 QUOTE

No problem to discuss to all. My intended use was with the "=" sign.
At the time, I was writing hundreds of lines of Lua code and probably rushed somethings to work as I wanted, at the moment and likely not the most general or best of breed.

You do bring up good ideas to reflect upon for further improvement.

Your presentation made me think of Klaus' bash functions, checkbootparam and getbootparam. The checkbootparam function behaves as in one of your examples, which would likely not be what would be intended, i.e., foobar=bar, checkbootparam(foo) returns sucess. I have had to always be wary of this, as it has tripped me on occasion.

But I think with all things code, there is always room for improvement especially when revisted.
Back to top
Profile PM WEB 
4 replies since July 16 2007,00:00 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: functions5.lua

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code