Thu, 21 Dec 2017 18:13:19 +0100 Daniel Caillibaud <ml@lairdutemps.org> écrivait : > Pourquoi ? > > $ [[ 'abcd' =~ '^ab' ]] && echo ok || echo KO > KO > > $ [[ 'abcd' =~ 'cd$' ]] && echo ok || echo KO > KO > > ?? Parce qu'entre guillemets, les caractères ^ et $ sont considérés comme des caractères normaux. $ set -x $ [[ 'abcd' =~ '^ab' ]] && echo ok || echo KO + [[ abcd =~ \^ab ]] + echo KO KO $ [[ 'abcd' =~ ^'ab' ]] && echo ok || echo KO + [[ abcd =~ ^ab ]] + echo ok ok $ [[ 'abcd' =~ 'cd$' ]] && echo ok || echo KO + [[ abcd =~ cd\$ ]] + echo KO KO $ [[ 'abcd' =~ 'cd'$ ]] && echo ok || echo KO + [[ abcd =~ cd$ ]] + echo ok ok un petit "set -x" fonctionne bien, même dans une session interactive. Joyeux Noël !!! Jean-Marc <jean-marc@6jf.be>
Attachment:
pgp3gJyzxAvxy.pgp
Description: PGP signature