You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2019/11/14 13:27:00 UTC

[jira] [Commented] (GROOVY-9310) Groovy does not ignore second bash directive

    [ https://issues.apache.org/jira/browse/GROOVY-9310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16974247#comment-16974247 ] 

Paul King commented on GROOVY-9310:
-----------------------------------

The current behavior is to just allow the special bash comment for the first line.

Antlr2:
https://github.com/apache/groovy/blob/master/src/main/antlr2/org/codehaus/groovy/antlr/groovy.g#L477

Antlr4:
https://github.com/apache/groovy/blob/master/src/antlr/GroovyLexer.g4#L943-L944


> Groovy does not ignore second bash directive
> --------------------------------------------
>
>                 Key: GROOVY-9310
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9310
>             Project: Groovy
>          Issue Type: Bug
>          Components: command line processing
>            Reporter: John Mercier
>            Priority: Major
>
> When creating a groovy script for nixos I ran into an issue. Here is the script.
>  
> {code:java}
> #! /usr/bin/env nix-shell
> #! nix-shell -i groovy -p groovy
> println "hello"
> {code}
> The script uses a second bash directive which tells nix-shell to run the script using groovy. Groovy gives the following error.
>  
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> /home/john/projects/netbeans/update-nix-dependencies.groovy: 2: unexpected char: '#' @ line 2, column 1.
>    #! nix-shell -i groovy -p groovy
>    ^
> 1 error
> {code}
> This seems to be a groovy issue and I was wondering how it could be fixed. There is a workaround for nix-shell described [here|https://discourse.nixos.org/t/how-to-use-nix-shell-with-groovy/4779/2?u=moaxcp]. I'm willing to submit a pull request for this but I'm not sure where to start. Thanks!



--
This message was sent by Atlassian Jira
(v8.3.4#803005)