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

Support shell scripting (i.e. `#!/usr/bin/env red`) #2356

Closed
typeless opened this Issue Dec 4, 2016 · 12 comments

Comments

Projects
None yet
4 participants
@typeless

typeless commented Dec 4, 2016

I tried to write a script on MacOSX as follows

#!/usr/bin/env red

print "hello world\n"

But it outputs

** Script Error: Invalid compressed data - problem: -3
** Near: script: decapsulate 
if none? script

Maybe this is not supported yet?

I don't know much about the language but I think scripting, which accounts for a good portion of my daily job, would be a nice start point for exploring it.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 4, 2016

I don't know whether it is supported or not.

But you are not using the red header in the code..
Try this instead -

#!/usr/bin/env red
Red []
print "hello world\n"

ghost commented Dec 4, 2016

I don't know whether it is supported or not.

But you are not using the red header in the code..
Try this instead -

#!/usr/bin/env red
Red []
print "hello world\n"
@typeless

This comment has been minimized.

Show comment
Hide comment
@typeless

typeless Dec 4, 2016

@nc-x

Thanks for your reply.

It doesn't work with the header either.

typeless commented Dec 4, 2016

@nc-x

Thanks for your reply.

It doesn't work with the header either.

@geekyi

This comment has been minimized.

Show comment
Hide comment
@geekyi

geekyi Dec 4, 2016

Contributor

Oh wait, you actually have red Red [] (it is what the interpreter interprets as)
Try:

#!/usr/bin/env red
[]
print "hello world\n"
Contributor

geekyi commented Dec 4, 2016

Oh wait, you actually have red Red [] (it is what the interpreter interprets as)
Try:

#!/usr/bin/env red
[]
print "hello world\n"
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 4, 2016

@geekyi
I may be wrong but since the compiler and interpreter just ignore anything before Red [] so red Red [] should not be a problem (someone needs to check it)?

@typeless
Try the solution at the end of #543 , maybe it works.
Also check whether you are able to run the Red Console (interpreter) and compiler or does it also show some error.

I will let someone with UNIX answer this now.

ghost commented Dec 4, 2016

@geekyi
I may be wrong but since the compiler and interpreter just ignore anything before Red [] so red Red [] should not be a problem (someone needs to check it)?

@typeless
Try the solution at the end of #543 , maybe it works.
Also check whether you are able to run the Red Console (interpreter) and compiler or does it also show some error.

I will let someone with UNIX answer this now.

@geekyi

This comment has been minimized.

Show comment
Hide comment
@geekyi

geekyi Dec 4, 2016

Contributor

@nc-x Yeah, red Red[] works as a valid program. Red Red[] is invalid. Other combinations give mixed results

Contributor

geekyi commented Dec 4, 2016

@nc-x Yeah, red Red[] works as a valid program. Red Red[] is invalid. Other combinations give mixed results

@geekyi

This comment has been minimized.

Show comment
Hide comment
@geekyi

geekyi Dec 4, 2016

Contributor

Invalid compressed data - problem: -3

@typeless that's a really strange error, it's commented out in the code since a long time??:
448a726#diff-12bb3846a732df68864adba72da97ed1R109

(On second thought, this might actually be rebol code)
Which build are you using? Does the red binary work on it's own?

Probably a path issue as nc-x has pointed out. Try using the full path to red binary.
See also #1547

Contributor

geekyi commented Dec 4, 2016

Invalid compressed data - problem: -3

@typeless that's a really strange error, it's commented out in the code since a long time??:
448a726#diff-12bb3846a732df68864adba72da97ed1R109

(On second thought, this might actually be rebol code)
Which build are you using? Does the red binary work on it's own?

Probably a path issue as nc-x has pointed out. Try using the full path to red binary.
See also #1547

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost commented Dec 4, 2016

Yep, that's the workaround. See here - https://gitter.im/red/red?at=56f80fc276b6f9de194ba1e6

@dockimbel

This comment has been minimized.

Show comment
Hide comment
@dockimbel

dockimbel Dec 5, 2016

Member

The Invalid compressed data - problem: -3 is an error from Rebol "decapper", in charge of decompressing the embedded payload (the Red toolchain source code) in memory, before running it. The common workaround for that, is to wrap red executable in a shell script, which could be used as a substitute:

#!/bin/bash
red $@

OTOH, you can use the precompiled console (located in .red/ folder), to run Red scripts in interpreted mode. That binary should work fine when directly invoked from a shebang line.

Member

dockimbel commented Dec 5, 2016

The Invalid compressed data - problem: -3 is an error from Rebol "decapper", in charge of decompressing the embedded payload (the Red toolchain source code) in memory, before running it. The common workaround for that, is to wrap red executable in a shell script, which could be used as a substitute:

#!/bin/bash
red $@

OTOH, you can use the precompiled console (located in .red/ folder), to run Red scripts in interpreted mode. That binary should work fine when directly invoked from a shebang line.

@typeless

This comment has been minimized.

Show comment
Hide comment
@typeless

typeless Dec 5, 2016

@geekyi @nc-x @dockimbel Thanks for your supports.

I tried the 'wrapper' way and change my script as follows

#!/usr/bin/env red

Red []

print "hello world\n"

And it outputs

*** Error: not a Red program!

Maybe I missed something.

I'll leave this open and look forward to the feature being fully implemented. This is not an urgent issue by any means so please take your time.

typeless commented Dec 5, 2016

@geekyi @nc-x @dockimbel Thanks for your supports.

I tried the 'wrapper' way and change my script as follows

#!/usr/bin/env red

Red []

print "hello world\n"

And it outputs

*** Error: not a Red program!

Maybe I missed something.

I'll leave this open and look forward to the feature being fully implemented. This is not an urgent issue by any means so please take your time.

@geekyi

This comment has been minimized.

Show comment
Hide comment
@geekyi

geekyi Dec 5, 2016

Contributor

@typeless now try the workaround I mentioned in #2356 (comment)
Should probably open a separate bug for this?

Contributor

geekyi commented Dec 5, 2016

@typeless now try the workaround I mentioned in #2356 (comment)
Should probably open a separate bug for this?

@typeless

This comment has been minimized.

Show comment
Hide comment
@typeless

typeless Dec 6, 2016

@typeless now try the workaround I mentioned in #2356 (comment)
Should probably open a separate bug for this?

@geekyi I don't have access to my MacOSX machine right now. I'll follow your advice once I am back home.

typeless commented Dec 6, 2016

@typeless now try the workaround I mentioned in #2356 (comment)
Should probably open a separate bug for this?

@geekyi I don't have access to my MacOSX machine right now. I'll follow your advice once I am back home.

@typeless

This comment has been minimized.

Show comment
Hide comment
@typeless

typeless Dec 6, 2016

@typeless now try the workaround I mentioned in #2356 (comment)
Should probably open a separate bug for this?

@geekyi It works!

Now the remaining problem is the call function seems not supported yet.

typeless commented Dec 6, 2016

@typeless now try the workaround I mentioned in #2356 (comment)
Should probably open a separate bug for this?

@geekyi It works!

Now the remaining problem is the call function seems not supported yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment