Package: devscripts
Version: 2.21.3+deb11u1
Tags: patch

I have a user-installed program called "read-foobar".  When
I use checkbashisms on a script that calls that, it consid-
ers this a bashism:

| root@26dda7136b02:/# checkbashisms <<EOF
| > #!/bin/sh
| > read-foobar
| > EOF
| possible bashism in (stdin) line 2 (read without variable):
| read-foobar
| root@26dda7136b02:/#

(Is there some special semantics in bash for commands begin-
ning with "read-" that I am missing?)

The matching regular expression is:

|         $LEADIN
|           . qr'read\s*(?:-\w+\s*)*(?:\".*?\"|[\'].*?[\'])?\s*(?:;|$)' =>
|           q<read without variable>,

This appears to be intended to match "read" and then zero or
more options followed by an optional string literal.  So a
quick and dirty fix would be:

|         $LEADIN
|           . qr'read(?:\s+(?:-\w+\s*)*(?:\".*?\"|[\'].*?[\'])?)?\s*(?:;|$)' =>
|           q<read without variable>,

to match only on "read", optional whitespace and end-of-com-
mand, or "read", whitespace, the existing pattern and end-
of-command.

A test case would be:

| read-foobar
| read-foobar -r
| read-foobar file.txt

not being marked as bashisms.

Reply via email to