Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 18th, 2005, 12:33 PM   #1
levk
Newbie
 
Join Date: Jul 2005
Posts: 7
Rep Power: 0 levk is on a distinguished road
case with optional breaks

Is there a way to turn off breaks in a case clause? That is, it would fall through to the next case like in C if you don't put the "break"

I need to write a script for work that collects logs and the user can specify which log to collect or collect all by default.

Edit: This is in bash preferably
levk is offline   Reply With Quote
Old Jul 18th, 2005, 12:57 PM   #2
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
not sure, I have never done that in bash. You could just do ifs without the else if you don't figure it out, though.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Jul 18th, 2005, 1:42 PM   #3
levk
Newbie
 
Join Date: Jul 2005
Posts: 7
Rep Power: 0 levk is on a distinguished road
have you done this in some other shell? bash case doesn't look to have any options do other shells' cases have options? the best case scenario would be if I could just put an option up top to fall through

Edit: Alternatively... Can I define my own command or a macro like 'case' or is that impossible
levk is offline   Reply With Quote
Old Jul 18th, 2005, 2:05 PM   #4
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
I am only proficient in BASH, so I don't know about other shells. I don't think there is a keyword or anything of that nature which you could add to the case block to make it not break after a match. I would probably do this using ifs without elses - and if I wanted to make the fallover property switchable, I would write the regular case version (breaks) also and just do an if/else above both methods, using a decision variable that you set early in the script.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:39 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC