E020 doesn't report things like '^foo() {'

Bug #2050064 reported by Denis Silakov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash8
New
Undecided
Unassigned

Bug Description

The comment at https://opendev.org/openstack/bashate/src/branch/master/bashate/bashate.py#L110 states "# catch the case without "function", e.g. things like '^foo() {'"

However, it doesn't work as expected - bashate doesn't produce any error if we use "foo() {" in the script.

The thing is that the regexp used there is wrong - it matches only spaces as function name, I believe this was just a typo.

A single fix makes this work as expected:

- if re.search(r'^\s*?\(\)\s*?\{', line):
+ if re.search(r'^\S*?\(\)\s*?\{', line):

Moreover, it's not clear why we need '?' here, so we can optimize this even further:

- if re.search(r'^\s*?\(\)\s*?\{', line):
+ if re.search(r'^\S*\(\)\s*\{', line):

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.