Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redir variable parsing bug #582

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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