Skip to content

Commit

Permalink
Fix redir variable parsing bug (#582)
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantinos Kallas <[email protected]>
  • Loading branch information
angelhof authored Jun 22, 2022
1 parent 3ead49c commit e8e097c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
24 changes: 12 additions & 12 deletions compiler/parser/ceda/ast2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,25 @@ def mk_file (ty, n):
return ["File", [ty, n.nfile.fd, arg]];


def mk_dup (ty, n):
ndup = n.ndup;
vname = ndup.vname;

tgt = [];
def mk_dup(ty, n):
ndup = n.ndup
vname = ndup.vname
tgt = []

if (not vname):
dupfd = ndup.dupfd;
dupfd = ndup.dupfd
if (dupfd == -1):
tgt.append (["C", ORD_MINUS]);
tgt.append(["C", ORD_MINUS])
else:
dupfd_str = str (dupfd);
dupfd_str = str(dupfd)

for i in range (len (dupfd_str)):
tgt.append (["C", ord (dupfd_str [i])]);
for i in range(len(dupfd_str)):
tgt.append(["C", ord(dupfd_str[i])])
else:
tgt = to_arg (vname.narg);
tgt = to_arg(vname.contents.narg)

return (["Dup", [ty, ndup.fd, tgt]]);
return (["Dup", [ty, ndup.fd, tgt]])


def mk_here (ty, n):
Expand Down
10 changes: 10 additions & 0 deletions evaluation/tests/interface_tests/redir-var-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
func_emit_tests_Makefile_am ()
{
ofd=3
{
echo hi
} >&$ofd
}
fd=1
echo hi >&$fd
7 changes: 7 additions & 0 deletions evaluation/tests/interface_tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ test_exclam()
$shell test-exclam.sh
}

test_redir_var_test()
{
local shell=$1
$shell redir-var-test.sh
}

## We run all tests composed with && to exit on the first that fails
if [ "$#" -eq 0 ]; then
run_test test1
Expand Down Expand Up @@ -337,6 +343,7 @@ if [ "$#" -eq 0 ]; then
run_test test_quoting
run_test test_var_assgn_default
run_test test_exclam
run_test test_redir_var_test
else
for testname in $@
do
Expand Down

0 comments on commit e8e097c

Please sign in to comment.