Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am a bit surprised to not see a forum for scripting, maybe one for each shell. This is probably a newbie question so it goes here.
While checking out the case statement I see that case values are terminated by an close parenthesis. An unbalanced close parenthesis. And none of the places I have visited mention this oddity.
REALLY!?! Couldn't use something that does not come in matching pairs, like a colon?
This will cause problems with editors that help find matching parens, braces, and brackets.
Stroll on over to the Programming forum where you will find members eager to help with all programming questions, including shell scripting!
The unmatched parenthesis syntax of the shell case statement is simply that, a syntax construct with historical roots in an earlier language as I recall. It is often commented on, and perhaps an oddity in comparison to other languages and human habits, but it works and is what it is - a syntax tool to be used by the programmer!
Last edited by astrogeek; 01-19-2018 at 02:16 PM.
Reason: typo
I was thinking that scripting is different from programming, but that is cool. I will use it next time.
I found a couple of tutorials on bash and the case statement and nothing was said about that oddity.
Thank you for taking the time to reply.
The umatched parens even caused a parser problem in bash <=3 and ksh88 concerning $(subshell).
Fortunately solved in bash 4 and ksh93.
But there has been a work-around: simply add the opening parenthesis!
Code:
case $x in ( [Yy]* ) echo "$x starts with Y";; esac
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.