Page MenuHomePhabricator

Script-and-regex linter documentation does not make it clear enough that you really have to do what it says
Open, Needs TriagePublic

Description

There are multiple sources (https://secure.phabricator.com/diffusion/ARC/browse/master/src/lint/linter/ArcanistScriptAndRegexLinter.php, https://secure.phabricator.com/book/phabricator/article/arcanist_lint_script_and_regex/) describing how to use the script-and-regex linter. The sources say that the file path is passed as first argument to the script and can therefore be used as $0 in the script definition.

Reproduction steps:

  • Create linter configuration
.arclint
{
  "linters": {
    "sass": {
      "type": "script-and-regex",
      "include": "(\\.s+(a|c)ss$)",
      "script-and-regex.script": "sass-lint -v -q --format=compact \"$0\" || true",
      "script-and-regex.regex": "/^(?P<file>.*): line (?P<line>[0-9]*), col (?P<char>[0-9]*), (?P<warning>Warning|Error) - (?P<message>.*)$/m"
    }
  }
}
  • create a foo.sass sass file and add some content
  • run arc lint

Expected result:

The linter will be called and the filename will be passes as first arguemnt to the defined script-and-regex.script

sass-lint -v -q --format=compact "foo.sass" || true

Actual result:

The file is appended to the script path.
sass-lint -v -q --format=compact "" || true foo.sass

The problem is, that the lint command is build like this:
$future = new ExecFuture('%C %s', $this->script, $path);

Event Timeline

The use of sh as it is written in the documentation is important.

This is what you are intended to write:

$ sh -c 'echo "$0"' xxx
xxx

This is what it looks like you're writing:

$ echo $0 xxx
-bash xxx
epriestley renamed this task from File is not passed as argument to script-and-regex linter to Script-and-regex linter documentation does not make it clear enough that you really have to do what it says.Apr 6 2016, 8:21 AM

The use of sh as it is written in the documentation is important.
This is what you are intended to write:

$ sh -c 'echo "$0"' xxx
xxx

This is what it looks like you're writing:

$ echo $0 xxx
-bash xxx

Macro thatwasobvious:

Thanks...

chad added a project: Lint.May 2 2016, 7:56 PM