Hi Stephen, On 9/10/23 21:58, Stephen Lewis via Bugs and suggestions for GNU APL wrote: ...
When using 'apl' script in a pipeline I was surprised to find formatting clearly designed for a terminal when output was going to a file. Especially when the formatting has the effect of changing the shape of a matrix.
It does not. It merely folds the output at the point indicated by ⎕PW.
Many Unix commands behave differently when the output is not a terminal. Would it make sense for 'apl' to turn off terminal formatting when --script is in effect and the output is not a terminal?
The problem is that when printing into a file, APL cannot know if the folding of the output is desired or not. Some may want the folded output (e.g. to later cat it), some may not.
Also, APL cannot even know in a reliable way if the output goes to a file or to a terminal. In your case (forwarding to a file) all that APL sees is a file descriptor which is one end of a pipe to which the output goes. It cannot see the other end of that pipe (possibly a file but also possibly a terminal e.g. if the pipe is an ssh connection). The whole point of --PW is to tell APL where is shall fold the output. Unfortunately IBM APL2 says that ⎕PW has a minimum value of 30 so we cannot use 0 or -1 to suppress the folding. Therefore using large value is the only option remaining without breaking the APL2 compatibility of GNU APL. Best regards, Jürgen