On Thu, 2014-07-03 at 14:59 +0530, Amit Kucheria wrote:
> On Thu, Jul 3, 2014 at 2:22 PM, Jon Medhurst (Tixy) <t...@linaro.org> wrote:
> > On Thu, 2014-07-03 at 10:24 +0530, Amit Kucheria wrote:
> >> On Thu, Jul 3, 2014 at 7:37 AM, Lisa Nguyen <lisa.ngu...@linaro.org> wrote:
> > [...]
> >> > diff --git a/include/functions.sh b/include/functions.sh
> >> > index 6d75e34..d44706f 100644
> >> > --- a/include/functions.sh
> >> > +++ b/include/functions.sh
> >> > @@ -285,10 +285,10 @@ check_cpuhotplug_files() {
> >> >      shift 1
> >> >
> >> >      for i in $@; do
> >> > -        # skip check for cpu0
> >> > -        if [ `echo $dirpath | grep -c "cpu0"` -eq 1 ]; then
> >> > -            continue
> >> > -        fi
> >> > +        if [[ $dirpath =~ cpu0$ && $hotplug_allow_cpu0 -eq 0 ]]; then
> >>
> >> I just checked 'man bash' for the meaning of =~ and found this:
> >>
> >> "The return value is 0 if the string matches the pattern, and 1 otherwise."
> >>
> >> So if you find cpu0 in $dirpath, it'll return a zero, right? So your
> >> above expression becomes zero and you don't end up skipping the test
> >> for cpu0.
> >
> > But in shells, isn't zero true and non-zero false, and && behaves
> > accordingly?
> 
> I knew I was missing something. Thanks for the correction. No more
> morning reviews.
> 
> > I have another comment though, will the scripts only be used on systems
> > with bash? If we can't guarantee this perhaps bash specific features
> > should be avoided. (Is the android shell bash compatible?)
> 
> At the moment pm-qa depends on /bin/bash. While restricting ourselves
> to POSIX shell constructs would be ideal, I can't commit to doing a
> wholesale conversion anytime soon.
> 
> Having said that, I just confirmed with Vishal and Android doesn't
> care about #!/bin/bash. It just executes the shell script using
> /system/bin/sh. And we've been fixing any error reports, so it looks
> like the shell is Bash-compatible.

Well, for me on Android I get

   syntax error: '=~' unexpected operator/operand

when running a script containing

#!/bin/bash
foo=bar; if [[ $foo =~ $1 ]]; then echo yes; else echo no; fi

The same script runs OK on my PC, giving yes/no as appropriate to what I
pass as the argument.

So for the $subject patch, best to keep the existing check which uses
grep, and just make the 'continue' conditional, e.g.

if [ `echo $dirpath | grep -c "cpu0"` -eq 1 ]; then
        if [ $hotplug_allow_cpu0 -eq 0 ]; then continue; fi
fi




_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to