That will work in a shell. But if the IDE (the debugger) starts the exe, then shell stuff doesn't happen.
question:
is it for the same reason that if I use the REQUEST_METHOD environment variable set to GET, the debugger works correctly
whereas if I set it to POST it crashes on the Run statement?
Not sure about your question.
First of all, what crashes, the debugger or your app in the debugger?
But anyway, about the differences between running outside or inside the IDE (or inside an http server)
If you give a
shell the command-line
./myapp --data=~/data.txt >/tmp/log.txt
The shell will translate this. The shell will replace ~ with your home dir.
The shell will open the file /tmp/log.txt and set stdout to it.
Your app gets executed with the param "--data=/home/username/data.txt" and it gets a handle for stdout.
The http server also set stdout, and it does set additional environment.
---
The debugger does not translate "~".
And the debugger does not set stdout/stdin
The only thing the debugger currently does is set environment, if you specify it.
follow example code
#!/usr/bin/instantfpc
program TestCgi;
"instantfpc" doesn't matter to the debugger => you must have compiled the code, or set up the IDE to have it compiled before the debugger starts.
Another difference here.
A shell will look into the file, and recognize it starts with #!.
The shell will then call
/usr/bin/instantfpc the_file
The debugger will not do that. It expects an executable binary (with machine code in it).
Actually about stdin/stdout
Go to Tools > Options > Debugger > Backend
and choose "Gdb GNU debugger"
==> I think this should set up your stdin, if in "run parameters" you specify " <somefile "
What is planned....
* stdin/stdout
There is an open issue, and plans to implement stdin/stdout redirection to work with FpDebug.
That does
not include piping between commands like "echo 123 | yourapp"
* ~ (and others)
Not planned (Though the ~ would be trivial)
* #!
Not planned
At least not from the debuggers perspective. If someone implements that on the IDE side, so it would be done before the debugger gets involved, .... But I have no knowledge that anyone is looking at it.