rupesh4514 / grammatical-framework

Automatically exported from code.google.com/p/grammatical-framework
0 stars 0 forks source link

Weird output when executing system commands from the gf shell #60

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. start gf
2. enter a simple system command such as 'echo hello'

What is the expected output? What do you see instead?
expected:
    hello
seen:
    hello _tmpi

What version of the product are you using? On what operating system?
3.4-darcs on fedora

Please provide any additional information below.

Original issue reported on code.google.com by gregoire...@gmail.com on 10 Apr 2013 at 2:55

GoogleCodeExporter commented 9 years ago
If I start the GF shell and enter

    ! echo hello

I get the expected output:

    hello

Original comment by hallg...@chalmers.se on 10 Apr 2013 at 3:02

GoogleCodeExporter commented 9 years ago
It only does it with '?' ant not with all commands (I can't get help about '!'):

For instance it works with cat:
    > pt "hey" | ? cat
    hey

but not with tr 

    > pt "hey" | ? tr 'e' 'o'
    tr: extra operand ‘_tmpi’
    Try 'tr --help' for more information.

Original comment by gregoire...@gmail.com on 10 Apr 2013 at 3:10

GoogleCodeExporter commented 9 years ago
It seems that, for some reason (portability?), "?" doesn't create a pipe, but 
instead puts the input to the system command in a temporary file _tmpi and 
appends that filename to the end of the command. This should probably be 
changed, since it only works with commands that can take input from a named 
file (like cat, wc and grep, ...)

As a workaround, you can put a redirection symbol at the end of the command:

    ps "hey" | ? tr e o <

Original comment by hallg...@chalmers.se on 10 Apr 2013 at 3:24

GoogleCodeExporter commented 9 years ago
The system_pipe (aka "?") command creates a temporary file _tmpi containing
the input of the system command. It *both* appends _tmpi as an extra argument
to the system command line *and* adds an input redirection "< _tmpi". (It
also uses and output redirection "> _tmpo" to captures the output of the
command.)

With this patch, the _tmpi argument is no longer appended to the command line.
This allows system_pipe to work with pure filters, such as the "tr" command,
but it will no longer work with commands that require an explicit input file 
name.
(It is possible to use write_file instead...)

TODO: it would also be fairly easy to eliminate the creation of the _tmpi and
_tmpo files altogether.

Original comment by hallg...@chalmers.se on 12 Nov 2013 at 6:26