bug-apl
[Top][All Lists]
Advanced

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

Re: [Bug-apl] #!apl


From: Juergen Sauermann
Subject: Re: [Bug-apl] #!apl
Date: Tue, 21 Aug 2018 20:51:59 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

Hi,

it works on my box:

address@hidden:~/projects/juergen/apl-1.7/src$ cat test.apl
#!apl --script

"APL script started"
)OFF

address@hidden:~/projects/juergen/apl-1.7/src$ chmod 755 test.apl
address@hidden:~/projects/juergen/apl-1.7/src$ ./test.apl
APL script started

address@hidden:~/projects/juergen/apl-1.7/src$


Of course, as I said: using relative paths is asking for trouble.

/// Jürgen



On 08/21/2018 07:18 PM, Hudson Flavio Meneses Lacerda wrote:
On Tue, 21 Aug 2018 18:36:27 +0200
Juergen Sauermann <address@hidden> wrote:

Hi Hudson,

Hi,

aas far as I know you can use a relative path to apl as long as the
apl binary is in your $PATH. Thus '#!apl --script' probably works
regardless of whether apl is installed in /usr/loccal/bin or
in /user/bin.
/usr/local/bin is in $PATH, but #!apl does not work.

However, my own personal experience with relative paths is quite
negative and troubleshooting problems caused by relative paths can be
rather time-consuming. So one of my golden rules (another one
mentioned earlier) is: "always prefer absolute paths over relative
paths".
`ln -s /usr/local/bin/apl /usr/bin/apl` results in error, because apl
cannot find libraries by itself.

But I can stick with this absolute path (for bash instead of apl):


#!/bin/bash
':' ⎕EA''⍝;exec apl -s "$0" "$@"



The reason for #! comes from man(2) execve.
My question is about GNU APL reading .apl files with )copy or )load.

Thanks,
Hudson



/// Jürgen



On 08/21/2018 03:24 PM, Hudson Flavio Meneses Lacerda wrote:
Hi Jürgen,

Indeed, for my own local computer, I could install apl in /usr.

However, I also use third-part computers as restricted user ($), with
apl installed in a different path (under ~/).

Here is my new approach (trying to avoid side effects):

---8<----------------------------------
#!/bin/bash
'true' ⎕EA ''⍝;exec apl -s -f "$0" "$@"
⍝--------------------------------------
'⍝ Body of script'
   ⎕RL←×/⎕TS~0
   ?⍨ 20
'⍝ End of script'
)off
---------------------------------->8---

(That can work fine with bash or dash, but not with sash.)

By the way, why APL files need to start with "#!" to be accept by
)copy/load?

Cheers,
Hudson




On Tue, 21 Aug 2018 11:14:30 +0200
Juergen Sauermann <address@hidden> wrote:

Hi Hudson,

you can ./configure GNU APL with prefix=/usr and then recompile and
install.

/// Jürgen


On 08/21/2018 03:34 AM, Hudson Flavio Meneses Lacerda wrote:
Hi.

Some of my scripts use `#!/usr/bin/apl --script` (from Debian), but
now I am using SVN, so I should use `#!/usr/local/bin/apl --script`.
So, I need to change the scripts, that may be incompatible with
different environments…

I have tried:

#!/usr/bin/env apl
#!apl --script
#!/usr/bin/apl --script
#!/usr/local/bin/apl --script

So far, the best solution I could find (so that I do not need to
change the files in the future) is this file header:

----------------------------------------------------
#!
true ← ~false ← 0 ⍝; exec apl --script "$0" "$@"
----------------------------------------------------

Are there any better solutions?

Thanks,
Hudson













reply via email to

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