kawa.sh shell script improved

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

kawa.sh shell script improved

Per Bothner
The kawa.sh shell script (which is installed as kawa when *not* configuring with
--enable-kawa-frontend) now handles <-D and -J options.  It does this by moving
them before the kawa.repl class name.  (This requires a shell that supports arrays.)
In addition it sets the kawa.command.line property, which is used by
the (command-line) procedure.

The kawa.sh script is now also built when using Ant.

Let me know if you notice any problems.  In particular I haven't tested
kawa.sh on Windows (either the configure-built or Ant-built versions).

Also, it would be nice if someone were to update or replace the kawa.bat
file for Windows.  It may be reasonable to use PowerShell, since it
appears to come standard with Windows 7 and 8 (and is available for
older versions of Windows).
--
        --Per Bothner
[hidden email]   http://per.bothner.com/
Reply | Threaded
Open this post in threaded view
|

Re: kawa.sh shell script improved

Duncan Mak
How do I get kawa.sh? I can look into using it instead of the custom
wrapper in Homebrew for OSX.

The current wrapper looks like this:
https://github.com/Homebrew/homebrew/blob/master/Library/Formula/kawa.rb
(see the #install method)


Duncan.

On Wed, Nov 19, 2014 at 3:44 PM, Per Bothner <[hidden email]> wrote:

> The kawa.sh shell script (which is installed as kawa when *not* configuring
> with
> --enable-kawa-frontend) now handles <-D and -J options.  It does this by
> moving
> them before the kawa.repl class name.  (This requires a shell that supports
> arrays.)
> In addition it sets the kawa.command.line property, which is used by
> the (command-line) procedure.
>
> The kawa.sh script is now also built when using Ant.
>
> Let me know if you notice any problems.  In particular I haven't tested
> kawa.sh on Windows (either the configure-built or Ant-built versions).
>
> Also, it would be nice if someone were to update or replace the kawa.bat
> file for Windows.  It may be reasonable to use PowerShell, since it
> appears to come standard with Windows 7 and 8 (and is available for
> older versions of Windows).
> --
>         --Per Bothner
> [hidden email]   http://per.bothner.com/



--
Duncan.
Reply | Threaded
Open this post in threaded view
|

Re: kawa.sh shell script improved

Per Bothner


On 11/19/2014 02:19 PM, Duncan Mak wrote:
> How do I get kawa.sh? I can look into using it instead of the custom
> wrapper in Homebrew for OSX.
>
> The current wrapper looks like this:
> https://github.com/Homebrew/homebrew/blob/master/Library/Formula/kawa.rb
> (see the #install method)

kawa.sh is generated from bin/kawa.sh.in.
If using configure+make, it is created by the configure script.
If using Ant, it is generated by the kawa.sh target in build.xml.

I suggest changing your install target so kawa is generated by running
sed on kawa.sh.in.  See build.xml for what needs to be substituted.

For example:
   sed -e 's/@VERSION@/#{version}/' -e ... < kawa.sh.in >kawa
   chmod +x kawa

This assumes /bin/sh is a bash- or ksh-compatible shell that supports
arrays.  (This is needed for the -D -or -J options.)

The sed substitution should also change the setting of KAWALIB
so it defaults to the installed kawa-#{version}.jar.
See the install-binSCRIPTS rule in Makefile.am.
--
        --Per Bothner
[hidden email]   http://per.bothner.com/
Reply | Threaded
Open this post in threaded view
|

Re: kawa.sh shell script improved

Per Bothner


On 11/19/2014 04:04 PM, Per Bothner wrote:
> kawa.sh is generated from bin/kawa.sh.in.

Make sure you get a fresh check-out.

There is still one problem: What, if anything,
to put in the top #!! line.

#!/bin/sh works fine on systems where /bin/sh is bash.
Otherwise, it breaks if you try to use -D or -J options.

#!/bin/bash may not be available on all systems.
Plus it's needlessly restrictive, since the script also works on ksh.

Leaving out the #! line may fail if there is a system where the default
"shell" is not Bourne shell or compatible.  I know in the old days on BSD systems
the default shell was the users default shell.  I don't know if that is the
case on any modern system.
--
        --Per Bothner
[hidden email]   http://per.bothner.com/
Reply | Threaded
Open this post in threaded view
|

Re: kawa.sh shell script improved

Per Bothner


On 11/19/2014 04:18 PM, Per Bothner wrote:

> There is still one problem: What, if anything,
> to put in the top #!! line.
>
> #!/bin/sh works fine on systems where /bin/sh is bash.
> Otherwise, it breaks if you try to use -D or -J options.
>
> #!/bin/bash may not be available on all systems.
> Plus it's needlessly restrictive, since the script also works on ksh.
>
> Leaving out the #! line may fail if there is a system where the default
> "shell" is not Bourne shell or compatible.  I know in the old days on BSD systems
> the default shell was the users default shell.  I don't know if that is the
> case on any modern system.

I checked in a fix to use a new @KAWA_SHELL@ autoconf variable.
I.e. the first line of kawa.sh.in is now:
     #!@KAWA_SHELL@
and configure replaces that as specified.  It defaults to /bin/bash if
that file exists and /bin/sh otherwise.

The Ant build does the same, expect using a property build.xml.

I'm hoping this solves the problem.
--
        --Per Bothner
[hidden email]   http://per.bothner.com/