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

cant use w/ #!shebang #66

Closed
takano32 opened this issue Nov 24, 2011 · 10 comments
Closed

cant use w/ #!shebang #66

takano32 opened this issue Nov 24, 2011 · 10 comments

Comments

@takano32
Copy link
Contributor

Many script programming languages are commonly able to comment out w/ '#'.
Nimrod is also able to do it.

And many script programming languages are able to use w/ #!shebang.

!shebang is i.e.

#!/usr/bin/env gosh

(define (fib n)
  (if (< n 2) 1
    (+ (fib (- n 2)) (fib (- n 1)))))

(print (fib 30))

But Nimrod cant kick w/ #!shebang.

@takano32
Copy link
Contributor Author

And i wrote a Nimrod script kicker, cush named from nimrod's father. :-)

# cush.nim
import
  os, osproc

var nim = paramStr(1)
when defined(windows):
  var null = "nul"
  else:
  var null = "/dev/null"
var ret = execCmd("nimrod c " & nim & " > " & null)
var bin = changeFileExt(nim, "")
ret = execCmd(bin)

compile it and put it on $PATH.

And then fix hallo.nim in examples as below.

#!/usr/bin/env cush
# Hello world program

echo "Hello World!"

And you can now, just type

cd examples
./hallo.nim
Hello World!

Wow.

My Nimrod life is accelerated by cush and having more fun!

would you accept cush.nim and builtin build script?

@takano32 takano32 reopened this Nov 24, 2011
@takano32
Copy link
Contributor Author

sorry for miss closing. :-(

@Araq
Copy link
Member

Araq commented Nov 24, 2011

What about #! /usr/bin/nimrod c -r?

@takano32
Copy link
Contributor Author

thank you for your comment!

i know about its options, but i wrote cush.nim since below two reasons.

  • i cant make "-r" option completely be quiet. some output must be appeared.
    • even i tried cariblating hints messages.
  • /usr/bin/env is to use for supporting many kinds of user env. i.e. some user may have nimrod at /usr/local/bin/nimrod
    • but /usr/bin/env command dont relay args to what to be exec.

thankyou.

@Araq
Copy link
Member

Araq commented Nov 24, 2011

If you change your nimrod.cfg to contain --verbosity:0, --hints:off, --warnings:off the compile is completely quiet. ;-)

Your 'else' is actually not indented properly but the compiler does not complain and the grammar allows it too. :D I am unsure what to do about it because actually your way of indentation makes some sense too...

I close this issue because you found a nice solution to work around the problem which however I don't feel like adding to the distribution ;-) as the compiler's command line handling will change a bit in the future for better editor/IDE support.

@Araq Araq closed this as completed Nov 24, 2011
@takano32
Copy link
Contributor Author

thanks for your comment, and i feel ease for loadmap of command line and Edit/IDE support! :-)

thanks to ask me reason of this issue and how to solve it!

thank you.

@lee-b
Copy link

lee-b commented May 1, 2013

If cush works, might I request making it an part of the official part of the language (ideally under a more obvious, less namespace-polluting) name, like nimrod-script)?

The thing is, shebang support is often possible in one way or another, but making scripts just work on any plaform that has Nimrod installed... that's a big step forward.

@fowlmouth
Copy link
Contributor

I think silencing all output from the compiler is a bad idea, as it is it looks as if you're running a script interpreted. Maybe a message that says how long it took to compile or something.

@reactormonk
Copy link
Contributor

So we want self-compiling binaries now?

@fowlmouth
Copy link
Contributor

Now that I hear it Tass way I say YES that sounds like the future to me!

krux02 pushed a commit to krux02/Nim that referenced this issue Jan 11, 2022
66: [DOC] Link to the spec project instead of nim-lang#10 r=saem a=haxscramper



Co-authored-by: haxscramper <haxscramper@gmail.com>
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

No branches or pull requests

5 participants