I'm using git bisect to find out a version in which the VERSION file has changed from 0.0.1_testing to newer version and I want to use bisect run
like this.
git bisect run sh -c 'if [ "$(cat VERSION)" == "0.0.1_testing" ] ; then exit 0 ; else exit 1 ; fi'
But I keep getting bad result and this error sh: 1: [: 0.1.0: unexpected operator
(0.1.0 is
returned by "$(cat VERSION)"
. I assume that this is because when the subshell exits, bisect uses its exit value and doesn't even go through rest of the script.
Is there a way how to make this work? Or some good alternative? I know I could use other tools than bisect, but I'd really like to do it this way.
If you were using bash
you would be able to use either an =
or ==
for your string comparison, so one solution to your problem is to change sh
to bash
in your command. This is because, for bash
the test
command ([ ... ]
in your command) is a builtin command that supports both comparisons.
The shell you are using does not have the same builtin command and is using the system test
command which only has =
as the string comparison. So, an alternative solution to your problem is to change the ==
to =
in your command.