Très drôle et instructif ! Il faut lire complètement le man pour comprendre : An additional binary operator, =~, is available, with the same precedence as == and !=. When it is used, the string to the right of the operator is considered an extended regular _expression_ and matched accordingly (as in regex(3)). The return value is 0 if the string matches the pattern, and 1 otherwise. Du coup si : [[ 'abcd' =~ '^ab' ]] && echo ok || echo KO KO On a ceci qui répond bien : [[ 'abcd' =~ ^ab ]] && echo ok || echo KO ok petite blague de Noël…
-- Pierre Malard « Si, comme le disait le général de Gaulle, la France n'avait pas été la France... on peut logiquement penser que tous les français auraient été des étrangers » ;-) Pierre Dac |\ _,,,---,,_ /,`.-'`' -. ;-;;,_ |,4- ) )-,_. ,\ ( `'-' '---''(_/--' `-'\_) πr perl -e '$_=q#: 3|\ 5_,3-3,2_: 3/,`.'"'"'`'"'"' 5-. ;-;;,_: |,A- ) )-,_. ,\ ( `'"'"'-'"'"': '"'"'-3'"'"'2(_/--'"'"' `-'"'"'\_): 24πr::#;y#:#\n#;s#(\D)(\d+)#$1x$2#ge;print' - --> Ce message n’engage que son auteur <-- |
Attachment:
signature.asc
Description: Message signed with OpenPGP