Closed kimkim19642004 closed 5 years ago
Not really, unfortunately. The shebang is ignored, and only the selected bash parser (or the default bash in the path) is used. The version of the used bash is checked though, to know if it's possible to use the "BASH_XTRACEFD" instead of parsing stderr.
Often, the shebang is set to #!/bin/sh
, which can be e.g., dash or similar on some systems. These can't use the debugging features kcov needs, so it will always run bash even if the shebang says the script should be parsed by something else.
A special place where the shebang is parsed is in a dynamically loaded shared library:
https://github.com/SimonKagstrom/kcov/blob/master/src/engines/bash-execve-redirector.c
this is used to detect when another script is started from the covered script, to run coverage on that too. This particular one would fail with your shebang, so that might be a place to improve.
Thank you for your reply.
The problem was solved by examining the value of the shell variable BASH_VERSINFO.
I should have checked the parser in my shell scripts.
Dear Mr.Simon Kagstrom,
I created a shell script containing the shebang '#!/usr/bin/env bash' and tested it with kcov.
The test environment: Mac OS X on Travis CI
The kcov option: --bash-parser="$(which bash)" (default: /bin/bash)
The core of my question: Does 'kcov' check Bash's version described at the shebang in the shell script, and reports errors if there are any problems? If so, how to use 'kcov' will be easier...
Thank you