Re: [Bug-apl] #!apl
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
Re: [Bug-apl] #!apl
Hi I assume this Debian of which you speak is a linux distro of some sort? Use a link from the svn installed location /usr/local/bin/apl location to the location you have in your scripts /usr/bin/apl (from debian deb location) ln -sf /usr/local/bin/apl /usr/bin/apl then you don't have to change the scripts On Mon, 20 Aug 2018 22:34:56 -0300 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 > > > > >
Re: [Bug-apl] #!apl
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 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 > > > > > > >
Re: [Bug-apl] #!apl
Hi He might want to have both the deb and the svn on the same system On Tue, 21 Aug 2018 11:14:30 +0200 Juergen Sauermann 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 > > > > > > >
Re: [Bug-apl] #!apl
Hi Hudson, 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. 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". The reason for #! comes from man(2) execve. /// 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 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
Re: [Bug-apl] #!apl
On Tue, 21 Aug 2018 18:36:27 +0200 Juergen Sauermann 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 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 > > > > > > > > > >
Re: [Bug-apl] #!apl
Hi, it works on my box: eedjsa@server66:~/projects/juergen/apl-1.7/src$ cat test.apl #!apl --script "APL script started" )OFF eedjsa@server66:~/projects/juergen/apl-1.7/src$ chmod 755 test.apl eedjsa@server66:~/projects/juergen/apl-1.7/src$ ./test.apl APL script started eedjsa@server66:~/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 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 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
Re: [Bug-apl] #!apl
On Tue, 21 Aug 2018 20:51:59 +0200 Juergen Sauermann wrote: > Hi, > > it works on my box: Hi, I presume it works because apl binary is generated inside that directory (apl-1.7/src/), and "." is in your $PATH. So, "#!apl" calls "./apl" inside apl-1.7/src/. > > eedjsa@server66:~/projects/juergen/apl-1.7/src$ cat test.apl > #!apl --script Hudson
Re: [Bug-apl] #!apl
On Tue, Aug 21, 2018 at 04:54:52PM -0300, Hudson Flavio Meneses Lacerda wrote: > I presume it works because apl binary is generated inside that directory > (apl-1.7/src/), and "." is in your $PATH. So, "#!apl" calls > "./apl" inside apl-1.7/src/. That is the case, #!apl will work only when called from directory where the apl interpreter is. Content of PATH is entirely irrelevant, but the "apl" path is resolved using usual rules and it equivalent to "./apl" starting from current working directory at the time you call it (not even relative to location of the file). The typical way to get it to resolve the name using PATH is, of course, to abuse /usr/bin/env, but that's not viable because only one argument may be passed and GNU APL unfortunately requires --script to behave reasonably. Now, using polyglot code is the usual way to get around this (for example tclsh manual recommends this instead of using env), and I like the succinctness of the ⎕EA approach in comparison with some other variants proposed earlier (in 2016), but it could be done much easier by making GNU APL a bit smarter about that. Looks like everyone forgot, but exactly for this reason, since r735, invoking apl as aplscript implies the --script option. $ ln -s "$(which apl)" "${PATH%%:*}/aplscript" $ cat > test.apl << EOF > #!/usr/bin/env aplscript > 'YOLO' > )OFF > EOF $ chmod +x test.apl $ ./test.apl YOLO $ Perhaps it should be documented, because it's not. -k