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
Pages: (3) </ 1 [2] 3 >/

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

reply to topic new topic new poll
Topic: Auto mounter script., Mounts partitions for specified users.< Next Oldest | Next Newest >
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Sep. 29 2006,05:09 QUOTE

Jeah. I thought that too, but manuals never use then after elif.
But well. Let's try it anyway. =)


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Sep. 29 2006,06:08 QUOTE

Well it worked anyway. :D
Thanks. :)


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Sep. 29 2006,12:28 QUOTE

In addition to that, you might consider cutting down on your "if" statements, simply to make maintenance easier and keep it more readable.

If you're testing multiple (more than 2) values of a single variable I'd say "case" is much more appropriate.  This way all of your results of the $1 check can be put in an orderly manner, you won't have a huge amount of overlapping ifs and fis and thens to confuse, and then *I'll* be able to read it  :laugh:

Anyway, that's just opinion, but here's what I'd do....

Code Sample

if [ -n "$1" ]; then
case "$1" in
   mount)
       stuff for mount
   ;;
   umount)
       stuff for umount
   ;;
   *)
       stuff for every other $1 result
   ;;
esac
fi


Also, you don't have to test both -z $1 and -n $1.  If -z $1 is false and doesn't exit, you know -n $1 will be true.  If a case with -n $1 is the only code, including -z $1 is just redundant.


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





Group: Members
Posts: 3275
Joined: July 2006
Posted: Sep. 29 2006,21:58 QUOTE

Heh, nice review mikshaw.

I'll just add that you probably won't need to use 'then' after 'else' if you're just doing 1 (self-enclosed) command.
Back to top
Profile PM 
humpty Offline





Group: Members
Posts: 655
Joined: Sep. 2005
Posted: Sep. 29 2006,22:04 QUOTE

I dunno what the fuss is all about,

I just have a list of mount cmds in my script, don't care about any error msgs,
just ignore them.
Back to top
Profile PM 
14 replies since July 28 2006,05:27 < Next Oldest | Next Newest >

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

Pages: (3) </ 1 [2] 3 >/
reply to topic new topic new poll
Quick Reply: Auto mounter script.

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