Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

Skip #! in the beginning of a file #53

@ascii766164696D

Description

@ascii766164696D

I'm not sure if it's a bug, but following code is valid in nodejs, however it causes exception when it's parsed by narcissus.

#!/usr/local/bin/node
console.log(1)

I'm leaving here the fix in case someone want to edit a file with #! construction:
Edit /usr/local/narcissus/lib/jslex.js:210:

if (this.lineno == 1 && ch === '#' && next === '!') {
    for (;;) {
        ch = input[this.cursor++];
        next = input[this.cursor];
        if (ch === '\r') {
            if (next !== '\n') ch = '\n';
        }
        if (ch === '\n') {
            if (this.scanNewLines) {
                this.cursor--;
            } else {
                this.lineno++;
                break;
            }
        }
    }
} else

I'm sorry that I'm doing it here, just because https://github.com/mozilla/narcissus has no bug-tracker, and I think the fix might help someone.

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