-
Notifications
You must be signed in to change notification settings - Fork 516
let: count+=: Syntax Error on OS X 10.11.2 #140
Comments
That's weird; for me bash 4.3.42 works with bats just as well as bash 3.2. Can you try to reproduce the error with: bash -c 'echo $BASH; let count+=$(echo 1); echo $count' |
No, this looks good, I think.
I have an ENV var
|
Can you isolate the smallest test file that fails with the error you described originally? Ideally, |
I ran the built-in test suite:
Looking not that good, I'll investigate... let me know if you have a suggestion or need additional system info. |
I've been chasing down some permutations of this. It turns out that Apple has stuck to a patched version of bash based on 3.2.51 as this is the last version before bash cut over to GPLv3. While this is unfortunate, I think this is adequate reason to support this ancient bash version. (Bash can, of course, be easily upgraded on a per system basis with tools like MacPorts and brew, requiring a current bash version restricts out of the box bash support.) It appears bash has made many changes since 3.2.51, especially including behaviors with "set -e" that bats relies on heavily. What is the viability of back-porting bats to support bash 3.2.51 as well as the current bash releases. I am not a particularly proficient shell script developer, but am attempting some of this myself. (First order of business is to get bats unit tests passing.) Comments/Suggestions welcome Updated: as mentioned above, it looks like Mac OS X has moved bash up to 3.2.57 now, but I can't check until I boot my machine in the morning... (I don't expect there are major changes between bash 3.2.51 and 3.2.57.) |
@loren-osborn In bash, even the newer version, there's no reason for using
can always be rewritten to:
or safer:
See this http://unix.stackexchange.com/a/149832/38906 for more details. |
@Gnouc, great... That's the kind of help I find very useful. Currently I'm fighting with trap "bats_debug_trap \"\$BASH_SOURCE\"" debug and the backtrack capture mechanism. For some reason by the time I'm getting into Updated: I don't know if there's any difference with the trap, but |
@loren-osborn: I'm not sure, maybe the condition https://github.com/sstephenson/bats/blob/master/libexec/bats-exec-test#L216 is false? |
@Gnouc, Thanks... sorry... I did some more troubleshooting, and my debug output was getting discarded, leading me to false conclusions... I did confirm that the latest version of Mac OS X El Capítain includes 3.2.57(1), but that is still ancient next to 4.3 I have been doing research into this. I think these links have been rather helpful:
The deeper I dive into this rabbit hole, the more I'm starting to feel that The only think I can think of, and this is rather drastic, encouraging people to move to What do you think? (@sstephenson, this is a rather big proposed change. Can you share your opinion?) |
I wasn't able to track this down further... As a workaround I was using a
to run tests locally (on my Mac). |
I get the same error. I'm not really sure if this is relevant, and I'm no bash expert, but it might provide a hint towards the source of the problem. In my tests I have a /usr/local/Cellar/bats/0.4.0/libexec/bats-exec-suite: line 20: let: count+=: syntax error: operand expected (error token is "+=") The error disappears if I change the extension back to GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin15.0.0) and my bats version is: Bats 0.4.0 |
Is this solved? I am stuck with this. Getting the following error : /usr/local/Cellar/bats/0.4.0/libexec/bats-exec-suite: line 20: let: count+=: syntax error: operand expected (error token is "=") I am on Mac OS X 10.11.6 and bats version 0.4.0 |
I'm seeing the same issue as @manikanta-kondeti – anyone figured out a workaround? This worked just recently, but I updated to macOS Sierra 10.12.1 since then, and I think I might have installed bash via Homebrew because |
I took a stab at debugging this, and it turns out the error I got, which is the same as @manikanta-kondeti and @schmunk42, was kind of a red herring. I was using this bit of offending code in a script used in my tests via the project_dirname=$(readlink -m ./) This fails, because Thing is, I found out about this only due to @loren-osborn's comment about I ended up using this function to canonicalize the path, removing the |
PROBLEM: I was following the tutorial:
only when using the vbox official centos 6 box: If any *.bats test file has incorrect syntax, then this error happens in any box, even in bento box. FIX:
|
I got the same error.
|
Is this project died? This issue have been opened since the beginning of this year (2016). |
I got this. It's clear now. thx! |
Based on @Gnouc's comment above, I'm using this one-liner as a workaround in order to get my tests running in Travis:
Ain't pretty, but it works. This assumes you've installed bats using its
Edit: Here's a more robust version. |
via ivan-at-wiris sstephenson#140 (comment)
Bats has know issues with old versions of bash < 4.1 as explained in issues sstephenson#49 and sstephenson#140. These issues create confusion because bats runs the tests without errors, but the results of the tests are wrong. This patchs adds the capability to check for the bash version and exit if it's not supported.
I tried to run this test-suite locally on and got this error:
which hardly translates to
My bash version
Installed latest from
master
.The text was updated successfully, but these errors were encountered: