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

Skip #! in the beginning of a file #53

Open
ascii766164696D opened this issue Mar 24, 2013 · 0 comments
Open

Skip #! in the beginning of a file #53

ascii766164696D opened this issue Mar 24, 2013 · 0 comments

Comments

@ascii766164696D
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant