bug-apl
[Top][All Lists]
Advanced

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

Re: [Bug-apl] #!apl


From: Kacper Gutowski
Subject: Re: [Bug-apl] #!apl
Date: Tue, 21 Aug 2018 23:37:54 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

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



reply via email to

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