bug-apl
[Top][All Lists]
Advanced

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

Re: [Bug-apl] strange behavior of --


From: Juergen Sauermann
Subject: Re: [Bug-apl] strange behavior of --
Date: Mon, 6 Feb 2017 13:25:24 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

Hi,

i have added a check if stdin is open when GNU APL starts, SVN 881.

If you start the following script:

#!/usr/local/bin/apl -l 37 --script --

]BOXING ¯8
⎕ARG
)off


Then we can see if stdin is open on OSX and how apl is being called in OSX.

/// Jürgen


On 02/06/2017 11:21 AM, Juergen Sauermann wrote:
Hi Alexey,

yes. I changed it recently to fix the '--' issue.

A GNU APL script assumes that it was called by execve().  The expand_argv() function
"undoes" the behavior of execve(), which lumps together all arguments on the first script line
into argv[1] of GNU APL's main(argc, argv) functions. In that process the filename of the script
gets lost (or may not even exist, e.g. in a pipe) so -f could be used to tell the script where to
fetch its input. This is because execve() had already closed the file descriptor before it called
apl, so apl has no stdin when it starts. With -f you point apl to re-open the input file again.

/// Jürgen


On 02/05/2017 09:24 PM, Alexey Veretennikov wrote:
Ok, as I understand I need to take a look at
UserPreferences::expand_argv
and
UserPreferences::is_APL_script

correct?

Juergen Sauermann <address@hidden> writes:

Hi,

yes, most of this trouble is caused by how execve() works, which is quite different
on different platforms. And it happens before apl is being called so I cant do much
about it.

Sometimes it helps to start apl with -f so that the interpreter knows where to fetch
its input, like:

#!/usr/local/bin/apl -f /home/eedjsa/tmp/script --script --

/// Jürgen

On 02/04/2017 02:00 PM, Alexey Veretennikov wrote:

 Hi Juergen,

Something is apparently strange on OSX(?). With the latest version
when I run the same script below I get the silent input without
echoing, no output like below, and I have to blindly type )off manually
to exit interpreter.


Juergen Sauermann <address@hidden> writes:

 Hi Alexey,

I have changed the handling of command line options, SVN 877.

It now works like this:

script:

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

)copy 5 FILE_IO FIO∆errno
8⎕CR ⎕ARG
)off

output:

address@hidden:~/tmp$ ./script scriptarg
DUMPED 2017-01-28 22:57:44 (GMT+1)
┌→──────────────────────────────────────────────────────────┐

│┌→─────────────────┐ ┌→───────┐ ┌→─┐ ┌→───────┐
┌→────────┐│
││/usr/local/bin/apl│ │--script│ │--│ │./script│ │scriptarg││
│└──────────────────┘ └────────┘ └──┘ └────────┘
└─────────┘│
└∊──────────────────────────────────────────────────────────┘


/// Jürgen

On 02/03/2017 11:06 PM, Alexey Veretennikov wrote:

 Hi,

Yes ./script -- myarg works.

The problem is why I have to repeat -- in command line since I've
already specified it in the first line of the script, as it is specified
in documentiation.

Basically I would like to pass my arguments to the script without
mentioning "--" in the command line.

Juergen Sauermann <address@hidden> writes:

 Hi Alexey,

how about this:

address@hidden:~/tmp$ ./script -- arg**
**DUMPED 2017-01-28 22:57:44 (GMT+1)**
**┌→────────────────────────────────────────────────────┐**
**│┌→─────────────────┐ ┌→───────┐ ┌→───────┐ ┌→─┐ ┌→──┐│**
**││/usr/local/bin/apl│ │--script│ │./script│ │--│ │arg││**
**│└──────────────────┘ └────────┘ └────────┘ └──┘ └───┘│**
**└∊────────────────────────────────────────────────────┘*

There is no point (and it does not work) to put the arguments in the first line
of the script,
because if the script itself knows them then the rest of the script can use them
as well.

*⎕ARG *is what is passed to the script, not what is passed to the interpreter
mentioned in the script.
See also *man execve*.

/// Jürgen


On 02/03/2017 08:29 PM, Alexey Veretennikov wrote:

 Given the following script:
------------------------------------------
#!apl --script --
)copy 5 FILE_IO FIO∆errno
8⎕CR ⎕ARG
)off
------------------------------------------
when I try to run it like

./script.apl myarg

I get the error:

/script.apl myarg
unknown option 'myarg'
...

This happens on 833 and 1.5 and on both linux and osx.

In INFO file it explicitely states:

"Using ’—-’ as last argument on the first line of the script file
prevents any of the options given to the script to be interpreted as APL
options; all such options are passed to the application via ⎕ARG."

But it is not happening.











reply via email to

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