GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inconsistent behavior with commented script parameters · Issue #398 · scijava/scijava-common

Inconsistent behavior with commented script parameters #398

New issue
Copy link
New issue
Copy link
Closed
#403
Closed
Inconsistent behavior with commented script parameters#398
#403
Copy link

Description

@imagejan
imagejan
opened on Oct 13, 2020
Issue body actions

When #@ script parameters are commented out (with // or #, dependent on the language used), the behavior differs depending on the position of the parameter definitions in the script (due to the support of both old-style and new-style parameters).

Consider the following Groovy scripts (all working as expected):

/*
 * Some comment as header
 * (This script uses new-style parameter syntax)
 */
#@ String text
#@ String text
/*
 * (This script uses a new-style parameter, but at the beginning of the script)
 */
// @String text
/*
 * (Old-style parameters will only be parsed at the very beginning of the code)
 */

Now, in the scripts using the new-style (#@) syntax, if you comment out the script parameter with //, the first script will stop showing the dialog, while the second script will still prompt for the text parameter:

/*
 * The following parameter declaration will be ignored
 * because # is not at the beginning of the line
 */
// #@ String text
// #@ String text
/*
 * ^^^ !
 * The above parameter matches the old-style syntax, even if both // and # are present
 */

We can probably change this to respect (and ignore) comments if and only if the script is using new-style syntax, by changing how we match the line when parsing old-style parameters here:

scijava-common/src/main/java/org/scijava/script/process/ParameterScriptProcessor.java

Line 143 in 3d64e2a

if (line.matches("^[^\\w]*@.*")) {

The question is if that would break any scripts in the wild that rely on the current behavior. There's definitely some scripts already that rely on commenting script parameters, but it would probably be ok to restore consistent behavior if the commented parameter occurs at the very beginning of the script.

@ctrueden what's your opinion?

NB: the behavior for Python is the same: # #@String text is ignored, except if in the first line.

Activity

  1. ctrueden
    closed this as completedin #403on Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.