Pinned-Dependencies: show where exactly parsing fails (#1297)

Looks like due to https://github.com/mvdan/sh/issues/636
scorecard can't parse comments quoted with backticks like
```
cmd -a \
    -b `# withouth backticks -c below would be a separate command` \
    -c
```
and fails with something like
```
error parsing shell code: 82:26: reached EOF without closing quote `
```

This PR turns that message into
```
error parsing shell code: vagrant/bootstrap_scripts/arch-sanitizers-clang.sh: 82:26: reached EOF without closing quote `
```
which is a bit more useful.

Co-authored-by: laurentsimon <64505099+laurentsimon@users.noreply.github.com>
This commit is contained in:
Evgeny Vereshchagin 2021-12-08 04:52:08 +03:00 committed by GitHub
parent 6e013cf67d
commit 01ebb0dcf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -768,7 +768,7 @@ func nodeToString(p *syntax.Printer, node syntax.Node) (string, error) {
func validateShellFileAndRecord(pathfn string, content []byte, files map[string]bool,
dl checker.DetailLogger) (bool, error) {
in := strings.NewReader(string(content))
f, err := syntax.NewParser().Parse(in, "")
f, err := syntax.NewParser().Parse(in, pathfn)
if err != nil {
// Note: this is caught by internal caller and only printed
// to avoid failing on shell scripts that our parser does not understand.