Skip to content

test failed with bash 5.3 #83

@qaqland

Description

@qaqland

Error Message:

$ BATS_LIB_PATH=/usr/lib/bats bats test/assert_output.bats

 ✗ assert_output() --regexp <regexp>: returns 1 and displays an error message if <regexp> is not a valid extended regular expression
   (from function `assert_test_fail' in file test/test_helper.bash, line 28,
    in test file test/assert_output.bats, line 257)
     `assert_test_fail <<'ERR_MSG'' failed

Check the error message and find that one extra line is in output, it is from bash 5.3

// before
	  result = sh_regmatch (arg1, arg2, mflags);

// after
	  errstr = NULL;
	  result = sh_regmatch (arg1, arg2, mflags, &errstr);
	  if (result == 2)
	    {
	      if (errstr && *errstr)
		builtin_error (_("invalid regular expression `%s': %s"), arg2, errstr);
	      else
		builtin_error (_("invalid regular expression `%s'"), arg2);
	      free (errstr);
	    }

https://github.com/bminor/bash/commit/b8c60bc9ca365f8261fa97900b6fa939f6ebc303

so it is easy to reproduce this case:

$ [[ '' =~ [.* ]]
bash: [[: invalid regular expression `[.*': Missing ']'

$ bash --version
GNU bash, version 5.3.3(1)-release (x86_64-alpine-linux-musl)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions