Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure.ac: bashism: fix critical existence failure on systems with dash #517

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eli-schwartz
Copy link

Remove the consistent use of bashisms. An autoconf generated script is designed to work with POSIX sh, and contains a /bin/sh shebang. As a result, it cannot assume it will be run with bash, as it won't be.

The bashism in question is the double equals (==) operator for the test command. It is actually a bash-specific alias for the single equals operator. It behaves exactly the same, except more confusing. It contains no added functionality and no behavior changes, it is merely an additional alternate spelling. In exchange for doing nothing whatsoever, even in bash, it breaks muscle memory when writing POSIX sh scripts and tricks developers into writing the wrong thing.

It is terrible and should never be used under any circumstances. Ideally it would be removed altogether from GNU bash.

Fixes the following warnings when running configure:

./configure: 5011: test: x: unexpected operator
./configure: 5014: test: x: unexpected operator
./configure: 5017: test: x: unexpected operator
./configure: 8056: test: nox: unexpected operator
./configure: 8109: test: yesx: unexpected operator
./configure: 8120: test: 3: unexpected operator
./configure: 8144: test: unexpected operator
./configure: 9089: test: stdc++x: unexpected operator
./configure: 9937: test: 0: unexpected operator
./configure: 10084: test: 0: unexpected operator
./configure: 10207: test: 0: unexpected operator
./configure: 10283: test: 0: unexpected operator
./configure: 11363: test: x: unexpected operator
./configure: 11561: test: x: unexpected operator
./configure: 11634: test: xno: unexpected operator
./configure: 11663: test: xno: unexpected operator
./configure: 12490: test: 3: unexpected operator
./configure: 13150: test: no: unexpected operator
./configure: 13167: test: no: unexpected operator

And the following fatal errors when trying to compile, since the resulting conditionals failed to define $(PROTOCBIN):

make -j8
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/kismet.proto
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/http.proto
/bin/sh: 1: -I: not found
make: [Makefile:808: protobuf_cpp/kismet.pb.h] Error 127 (ignored)
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/datasource.proto
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/linuxbluetooth.proto
/bin/sh: 1: -I: not found
make: [Makefile:808: protobuf_cpp/http.pb.h] Error 127 (ignored)
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/eventbus.proto
/bin/sh: 1: -I: not found
make: [Makefile:808: protobuf_cpp/linuxbluetooth.pb.h] Error 127 (ignored)
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/kismet.proto
/bin/sh: 1: -I: not found
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/http.proto
/bin/sh: 1: -I: not found
/bin/sh: 1: -I: not found
make: [Makefile:808: protobuf_cpp/datasource.pb.h] Error 127 (ignored)
make: [Makefile:808: protobuf_cpp/eventbus.pb.h] Error 127 (ignored)
make: [Makefile:806: protobuf_cpp/kismet.pb.cc] Error 127 (ignored)
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/datasource.proto
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/linuxbluetooth.proto
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/eventbus.proto
/bin/sh: 1: -I: not found

For extra interest, the failing command begins with --flag i.e. a flag passed to protoc, which Make then interprets as "ignore errors for this command", which means output files are not created but the build then continues and produces significantly more confusing errors such as:

kis_external.h:51:10: fatal error: protobuf_cpp/kismet.pb.h: No such file or directory

… dash

Remove the consistent use of bashisms. An autoconf generated script is
designed to work with POSIX sh, and contains a /bin/sh shebang. As a
result, it *cannot* assume it will be run with bash, as it won't be.

The bashism in question is the double equals (`==`) operator for the
test command. It is actually a bash-specific alias for the single equals
operator. It behaves exactly the same, except more confusing. It
contains no added functionality and no behavior changes, it is merely an
additional alternate spelling. In exchange for doing nothing whatsoever,
even in bash, it breaks muscle memory when writing POSIX sh scripts and
tricks developers into writing the wrong thing.

It is terrible and should never be used under any circumstances.
Ideally it would be removed altogether from GNU bash.

Fixes the following warnings when running configure:

```
./configure: 5011: test: x: unexpected operator
./configure: 5014: test: x: unexpected operator
./configure: 5017: test: x: unexpected operator
./configure: 8056: test: nox: unexpected operator
./configure: 8109: test: yesx: unexpected operator
./configure: 8120: test: 3: unexpected operator
./configure: 8144: test: unexpected operator
./configure: 9089: test: stdc++x: unexpected operator
./configure: 9937: test: 0: unexpected operator
./configure: 10084: test: 0: unexpected operator
./configure: 10207: test: 0: unexpected operator
./configure: 10283: test: 0: unexpected operator
./configure: 11363: test: x: unexpected operator
./configure: 11561: test: x: unexpected operator
./configure: 11634: test: xno: unexpected operator
./configure: 11663: test: xno: unexpected operator
./configure: 12490: test: 3: unexpected operator
./configure: 13150: test: no: unexpected operator
./configure: 13167: test: no: unexpected operator
```

And the following fatal errors when trying to compile, since the
resulting conditionals failed to define $(PROTOCBIN):

```
make -j8
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/kismet.proto
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/http.proto
/bin/sh: 1: -I: not found
make: [Makefile:808: protobuf_cpp/kismet.pb.h] Error 127 (ignored)
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/datasource.proto
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/linuxbluetooth.proto
/bin/sh: 1: -I: not found
make: [Makefile:808: protobuf_cpp/http.pb.h] Error 127 (ignored)
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/eventbus.proto
/bin/sh: 1: -I: not found
make: [Makefile:808: protobuf_cpp/linuxbluetooth.pb.h] Error 127 (ignored)
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/kismet.proto
/bin/sh: 1: -I: not found
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/http.proto
/bin/sh: 1: -I: not found
/bin/sh: 1: -I: not found
make: [Makefile:808: protobuf_cpp/datasource.pb.h] Error 127 (ignored)
make: [Makefile:808: protobuf_cpp/eventbus.pb.h] Error 127 (ignored)
make: [Makefile:806: protobuf_cpp/kismet.pb.cc] Error 127 (ignored)
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/datasource.proto
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/linuxbluetooth.proto
cpp_out=./protobuf_cpp/ -I protobuf_definitions/ protobuf_definitions/eventbus.proto
/bin/sh: 1: -I: not found
```

For extra interest, the failing command begins with `--flag` i.e. a flag
passed to protoc, which Make then interprets as "ignore errors for this
command", which means output files are not created but the build then
continues and produces significantly more confusing errors such as:

```
kis_external.h:51:10: fatal error: protobuf_cpp/kismet.pb.h: No such file or directory
```
@eli-schwartz
Copy link
Author

Hi, I've rebased against git master so the changes still apply.

@eli-schwartz
Copy link
Author

@dragorn is there anything outstanding I need to do to get this merged? The current state of affairs makes it quite challenging to build kismet on my system...

@eli-schwartz
Copy link
Author

ping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant