[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] scripting

From: Mark J. Reed
Subject: Re: [gforth] scripting
Date: Wed, 23 Dec 2015 09:20:45 -0500

You can also use the `env` program to make a script that doesn't rely on the specific location of gforth in the file system:

 #!/usr/bin/env gforth

That uses up your one extra argument, so you lose the ability to pass additional flags on the command line, but it makes your script more portable (on my system, for instance, gforth is in /usr/local/bin, so a #!/usr/bin/gforth line won't work).

On Wed, Dec 23, 2015 at 6:20 AM, Anton Ertl <address@hidden> wrote:
On Tue, Dec 22, 2015 at 07:50:49PM -0500, James Gere wrote:
> I think I read somewhere that some shells/implementations require a comment
> character in the shebang.  Gforth Manual I'm certain.

"#!" starts a comment (until the end of the line) in Gforth, and
that's there in order to allow Gforth scripts.  This means that you
have to put a space after #! (allegedly there is at least one Unix
variant that checks for "#! /", so the space is a good idea anyway).

For a .fs script, no additional flags are necessary.  If you call

bla.fs arg1 arg2

and bla.fs starts with

#! /usr/bin/gforth

this is equivalent

/usr/bin/gforth bla.fs arg1 arg2

which is probably what you want.  You can put *one* additional
argument (e.g., a flag) on the #! line; e.g., if you have the
following in bla.fs:

#! /usr/bin/gforth --die-on-signal

then the call abive is equivalent to

/usr/bin/gforth --die-on-signal bla.fs arg1 arg2

- anton

Mark J. Reed <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]