Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Read from stdin" broken in moonc #431

Closed
Sharparam opened this issue Dec 29, 2020 · 5 comments · Fixed by #432
Closed

"Read from stdin" broken in moonc #431

Sharparam opened this issue Dec 29, 2020 · 5 comments · Fixed by #432

Comments

@Sharparam
Copy link

According to the output of moonc -h, supplying the option - (and no other option) is supposed to read from stdin and output to stdout, but this doesn't seem to work:

$ moonc -
-       Can't find file  

Supplying the /dev/stdin works to circumvent it at least on Linux, but it makes for very wordy commands like:

$ cat <<EOF | moonc -p /dev/stdin
print 'Hello, World!'
EOF
return print('Hello, World!')  
@qaisjp
Copy link
Sponsor Contributor

qaisjp commented Dec 29, 2020

I think it is --, not -.

@Sharparam
Copy link
Author

It seems the help message in the dev version has changed, but the actual check still looks for --.

Here's the help message from dev version of moonc (luarocks install moonscript --dev):

❯ moonc -h
Usage: /usr/lib/luarocks/rocks-5.4/moonscript/dev-1/bin/moonc
       ([-t <output_to>] | [-o <o>] | [-p] | [-T] | [-b] | [-X]) [-h]
       [-l] [-v] [-w] [--transform <transform>] [-]
       <file/directory> [<file/directory>] ...

Arguments:
   file/directory

Options:
   -h, --help            Show this help message and exit.
   -l, --lint            Perform a lint on the file instead of compiling
   -v, --version         Print version
   -w, --watch           Watch file/directory for updates
   --transform <transform>
                         Transform syntax tree with module
            -t <output_to>,
   --output-to <output_to>
                         Specify where to place compiled files
   -o <o>                Write output to file
   -p                    Write output to standard output
   -T                    Write parse tree instead of code (to stdout)
   -b                    Write parse and compile time instead of code(to stdout)
   -X                    Write line rewrite map instead of code (to stdout)
   -                     Read from standard in, print to standard out (Must be only argument)

@qaisjp
Copy link
Sponsor Contributor

qaisjp commented Dec 29, 2020

Does it work when you do -- or is it only a problem with docs?

@Sharparam
Copy link
Author

Sharparam commented Dec 29, 2020

Using -- makes it work as expected yeah. So it's either the docs being wrong, or the code parsing wrong. A single dash is what I would expect, since that's how most unix commands function (a single dash to process stdin, two dashes to stop options processing, so everything after -- is treated as filenames).

@qaisjp
Copy link
Sponsor Contributor

qaisjp commented Dec 29, 2020

Yeah, I'd expect (and prefer) - too.

Although 9d11356 added it as -- and dd9661d broke it. I guess leafo will indicate his preference on your PR.

@leafo leafo closed this as completed in #432 Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants