Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:03:06+00:00 2026-06-04T07:03:06+00:00

Given the following: $ echo $BASH_VERSION 4.2.10(1)-release $ shopt | fgrep case nocaseglob off

  • 0

Given the following:

$ echo $BASH_VERSION
4.2.10(1)-release

$ shopt | fgrep case
nocaseglob      off
nocasematch     off

$ case A in [a-z]) echo TRUE;; esac
TRUE

I expect that the capital letter A should not match the lower-case character class of [a-z], but it does. Why doesn’t this match fail?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:03:07+00:00Added an answer on June 4, 2026 at 7:03 am

    You can’t reliably use the dash this way. If I don’t use dashes, it works as expected:

    $ bash --version
    GNU bash, version 4.2.10(1)-release (x86_64-pc-linux-gnu)
    Copyright (C) 2011 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    
    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    $ shopt -s nocasematch
    $ case A in [abc]) echo TRUE;; esac
    TRUE
    $ shopt -u nocasematch
    $ case A in [abc]) echo TRUE;; esac
    $ 
    

    But with dashes, it prints TRUE regardless of the setting of nocasematch.

    Bash is doing pattern matching here. Check out this section of the reference manual where it says that using the hyphen MIGHT interpret [a-z] as [A-Za-z]! It tells you how to get the traditional interpretation (set LC_COLLATE or LC_ALL to C). Basically your default locale is sorting in dictionary order. The reference manual explains things pretty well.

    ADDENDUM

    Okay I have a transcript for you.

    $ shopt -u nocasematch
    $ case A in [a-z]) echo TRUE;; esac
    TRUE
    $ shopt -s nocasematch
    $ case A in [a-z]) echo TRUE;; esac
    TRUE
    $ LC_ALL=C
    $ shopt -u nocasematch
    $ case A in [a-z]) echo TRUE;; esac
    $ shopt -s nocasematch
    $ case A in [a-z]) echo TRUE;; esac
    TRUE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following code: @Echo off ECHO Start ECHO Calling SUB_A CALL :SUB_A ECHO
Given the following command, echo "1: " | awk '/1/ -F ":" {print $1}'
Given the following Ruby program: def getch begin system(stty raw -echo) ch = STDIN.getc
Given the following two HTML/PHP snippets: <input type="text" name="firstname" value="<?php echo $_POST['firstname']; ?>" />
Given the following timestring: $str = '2000-11-29'; $php_date = getdate( $str ); echo '<pre>';
Given certain multibyte character sets, am I correct in assuming that the following doesn't
I am attempting to create an implode that given the following array: <?php $conditions
// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like
Given following Statment: String query = "Select * from T_spareParts where SparePartPK IN (?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.