-
Notifications
You must be signed in to change notification settings - Fork 39
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
Parse error in gnulib-tool #573
Comments
A similar error occurs also when executing the |
Thanks for reporting this! I narrowed down the issue in gnulib-tool to the following function: #!/bin/sh
func_emit_tests_Makefile_am ()
{
ofd=3
{
echo hi
} >&$ofd
} Based on PaSh's parser only supports POSIX compliant syntax (even though it runs scripts on bash under the hood). I don't see an immediate path for PaSh to support non-POSIX compliant syntax (that would not require significant engineering) since some of its transformations are built on the structure of the AST that is returned by a POSIX compliant dash parser reimplementation. After finding the parsing issue I replaced |
AFAIK most or all of gnulib is supposed to be compatible with POSIX shell so this should be fixable. Ditto configure scripts, fortunately! |
Thanks for trimming that down to a small test case; I would not have known how to do that.
I think it is POSIX compliant syntax, and shellcheck's warning is a bug: koalaman/shellcheck#2520 Additionally, for this slightly modified shell script
for which pa.sh fails to parse in the same way, shellcheck does not give a warning. |
Thanks for checking this! By the way, I only mentioned shellcheck as evidence that this is not POSIX compliant (I am not sure if we can trust it for absolute precision, it probably has both false positives and false negatives). We will investigate the parsing issue. At the same time, we will investigate the more important failures that happen once the script is parsed :) |
When you get to this stage, you'll need a GNU gnulib checkout (see https://savannah.gnu.org/git/?group=gnulib ) and put the script into the top-level directory of that checkout (so that it finds the various input files). |
I can confirm that the POSIX spec allows this behavior, and $ fd=2
$ echo hi >&$fd
hi
$ fd=3
$ echo hi >&$fd
/Users/mgree/smoosh/libdash/src/dash: 4: 3: Bad file descriptor Smoosh works as well, using the OCaml version of our bindings: $ fd=2
$ echo hi >&$fd
hi
$ fd=3
$ echo hi >&$fd
Bad file descriptor: 3 So I suspect there's a bug somewhere in our Python bindings or in our handling of the resulting AST. |
gnulib-tool
is a large shell script, from the GNU gnulib project. When I attempt to execute it through pash, with specific arguments, there is a parse error.Here is gnulib-tool-cmp, the gnulib-tool script with an extra line 45 that sets the arguments. For successful execution, you would also need a gnulib git checkout. But pa.sh fails to parse the script, even before it gets to reading other files.
gnulib-tool-cmd.gz
This is on an Ubuntu 22.04 machine.
The text was updated successfully, but these errors were encountered: