![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Jul 2005
Posts: 7
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jul 2005
Posts: 7
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|