help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: case insensitivity for some branch in the case statement


From: Greg Wooledge
Subject: Re: case insensitivity for some branch in the case statement
Date: Mon, 4 Nov 2019 08:55:59 -0500
User-agent: Mutt/1.10.1 (2018-07-13)

On Fri, Nov 01, 2019 at 11:12:20PM +0100, Eric Blake wrote:
> This is REALLY gross, but:
> 
> case abC in
>  abc) echo no;;
>  *) shopt -s nocasematch ;;&
>  abc) echo yes;;
> esac
> 
> which echoes yes, because the first pattern (abc) does NOT match
> case-sensitively, the second pattern (*) _does_ match, and the ;;&
> terminator forces bash to recheck the input against the third pattern (abc)
> at which point it DOES match case-insensitively.
> 
> But PLEASE don't abuse bash like that in your scripts.

If you don't want someone to do it, you shouldn't show them how to do
it.  Sure, it's "safety by obscurity", but when dealing with people like
this person, that's typically sufficient.

 6. When given a choice of solutions, the newbie will always choose the
    wrong one.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]