Gentoo Archives: gentoo-user

From: <jan.pradac@××××××.cz>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Bash 3.2/3.1 compatibility?
Date: Sat, 10 Nov 2007 08:48:53
Message-Id: 573.807-16089-1161577468-1194684176@seznam.cz
In Reply to: Re: [gentoo-user] Bash 3.2/3.1 compatibility? by Alex Schuster
1 Hi,
2
3 I have the same problem and I was trying to solve it few weeks ago,
4 after almost two weeks of searching and compiling I substituted =~ with expr:
5
6 - orig use with ~= :
7 # if [[ "test" =~ ".*" ]]; then echo "ok"; fi
8
9 - alternative use with expr :
10 # export TEST_VAR="test"
11 # if [[ ${#TEST_VAR} == `expr "${TEST_VAR}" : ".*"` ]]; then echo "ok"; fi
12
13 It's more complicated, but it works. I also posted this as a bug with bashbug,
14 but no reply arrived. I hope this will help a little.
15
16 Jan
17
18 > ------------ Pùvodní zpráva ------------
19 > Od: Alex Schuster <wonko@×××××××××.org>
20 > Pøedmìt: Re: [gentoo-user] Bash 3.2/3.1 compatibility?
21 > Datum: 10.11.2007 04:14:19
22 > ----------------------------------------
23 > Willie Wong writes:
24 >
25 > > The situation:
26 > > I have some bash scripts written. The scripts contains a lot of
27 > > string comparisons. Perhaps my code was buggy before, perhaps it was
28 > > not, but the change
29 > >
30 > > "Quoting the string argument to the [[ command's =~ operator now
31 > > forces string matching, as with the other pattern-matching
32 > > operators."
33 > >
34 > > between 3.1->3.2 complete breaks my script.
35 >
36 > Yeah, I had the same problem. Very annoying.
37 >
38 >
39 > > The question:
40 > >
41 > > Is there a switch that I can use to make bash run in some sort of
42 > > compatibility mode for the string comparison? I.e, can I somehow
43 > > force bash (in the script) to behave like before?
44 >
45 > I am pretty sure there is none. The suggested workaround is to put the
46 > string to be matched into a variable:
47 >
48 > <http://bashcurescancer.com/bash_faq_version_336_for_bash_version_32#SUB-E14>
49 >
50 > Wonko
51 > --
52 > gentoo-user@g.o mailing list
53 >
54 >
55 >
56 >
57 --
58 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] Bash 3.2/3.1 compatibility? Alex Schuster <wonko@×××××××××.org>