I wrote a basic bash function to test for the occurence of a string search argument in another string. Running it from the command line gives expected results. Running the same from a shell script fails. Can somebody show me the errors of my ways?
me@mylaptop $ line='someidentifier 123                     another identifier 789 065             theend'
me@mylaptop $ sarg='+([0-9])+([ ])another identifier'
me@mylaptop $ type strstr
strstr is a function
strstr ()
{
   [ "${1#*$2*}" = "$1" ] && return 1;
   return 0
}
me@mylaptop $ strstr "$line" "$sarg" ; echo "$?"
0
me@mylaptop $
My script:
me@mylaptop $ cat l.sh
#!/bin/bash
function strstr ()
{
   [ "${1#*$2*}" = "$1" ] && return 1;
   return 0
}
line='someidentifier 123                     another identifier 789 065             theend'
sarg='+([0-9])+([ ])another identifier'
echo '==='"$line"'==='
echo '==='"$sarg"'==='
strstr "$line" "$sarg"
echo "$?"
me@mylaptop $ ./l.sh
===someidentifier 123                     another identifier 789 065             theend===
===+([0-9])+([ ])another identifier===
1
me@mylaptop $

