LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 06-09-2010, 02:06 PM   #1
akelder
Member
 
Registered: Jan 2007
Distribution: debian on servers, ubuntu on desktops/laptops
Posts: 45

Rep: Reputation: 16
BASH - regex in a case statement


Hi, the following works and BASH doesn't complain, but VIM highlights the closing square bracket is if it sees a syntax error. Is there a better way to express regex in a case statement or is this an issue with VIM?

Code:
#!/bin/bash

  case $1 in
    [zZ] ) echo "you said z or Z";;
  esac
 
Old 06-09-2010, 02:42 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,770
Blog Entries: 4

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
Is it highlighted only when you're on it or the open bracket? Vim likes to highlight matching pairs like that. On my system I see it highlight both the open and the close when I'm on either - there is a difference in the bold for the one I'm on as opposed to its match but both are highlighted.

Last edited by MensaWater; 06-09-2010 at 02:47 PM.
 
Old 06-09-2010, 03:30 PM   #3
akelder
Member
 
Registered: Jan 2007
Distribution: debian on servers, ubuntu on desktops/laptops
Posts: 45

Original Poster
Rep: Reputation: 16
Yes, same here. When a bracket is selected, VIM highlights it with a flashing yellow/teal and the matching bracket with teal, but in this case it's highlighting the closing square bracket in red, without the opening or closing square brackets selected.

I've seen this before when I'd use a bashism in a script that starts with #!/bin/sh instead of #!/bin/bash so it definitely looks like it's trying to alert me to a syntax error..

Last edited by akelder; 06-09-2010 at 03:36 PM.
 
Old 06-09-2010, 04:02 PM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,008

Rep: Reputation: 110Reputation: 110
Vim can occasionally get syntax highlighting wrong. Shell is definitely not the easiest language to parse.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
escape '*' in case statement bash junust Programming 2 01-23-2010 03:54 AM
[SOLVED] BASH --> esc key in a case statement manwithaplan Linux - Newbie 6 10-05-2009 10:33 PM
Pattern matching in a bash case statement using regex ciphyre Programming 1 01-31-2009 12:20 PM
bash case statement with multiple command line options pwc101 Programming 16 06-01-2007 11:43 AM
Pattern matching with a "case" statement in BASH King V Programming 8 04-27-2006 04:19 PM


All times are GMT -5. The time now is 01:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration