phhusson / super-bootimg

Tools to edit Android boot.img. NDK buildable, to be usable in an update.zip
GNU General Public License v3.0
226 stars 121 forks source link

Fix =~ bash operator detection #45

Closed PerfectSlayer closed 7 years ago

PerfectSlayer commented 7 years ago

There is a problem with the "=~" operator support detection (and maybe the shell -e option). As the command fails, the script stops. So the command should be in a subshell if you would like to test its support without breaking the whole script.

phhusson commented 7 years ago

Your explanation is not exactly true: This is actually a bug of mksh, which stops the scripts when it hits a parse error, but this shouldn't be a parse error, just a standard call to [

Anyway, that's a really great fix, I was afraid of needing a higher complexity , thanks!

PerfectSlayer commented 7 years ago

Thanks for the explanation! You're welcome. I'm glad to help 😉

phhusson commented 7 years ago

Oh, I'm wrong, it's [[ not [, thus it is not just an external program execution. I still think it's not supposed to quit this way...

I'm being told your fix doesn't work. Have you successfully tested it on your side? I'm currently having someone test with "sh -c '[[ "toto2" =~ "toto" ]]' && good_expr=1"

PerfectSlayer commented 7 years ago

I tested it on my side with my local shell (not mksh) and it worked fine. But you still have the syntax error log but the main script no more exits.