Skip to content

run with options overwrites the value of i #726

@kolyshkin

Description

@kolyshkin

Describe the bug

The value of a variable i gets overwritten if run uses any flags.

To Reproduce
Steps to reproduce the behavior:

  1. Create the file a.bats:
bats_require_minimum_version 1.5.0

@test i {
  for ((i=0; i<3; i++)) {
    echo before $i
    run ! false
    echo after $i
  }
}
  1. Run it:
bats --show-output-of-passing-tests a.bats
  1. See what happens:
   before 0
   after 2

Expected behavior

I have expected the following output:

   before 0
   after 0
   before 1
   after 1
   before 2
   after 2

Environment (please complete the following information):

  • Bats Version: 1.9.0
  • OS: Linux
  • Bash version: 5.2.15

Additional context
A variable i is not declared as local in a few functions in common.bash.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions