Permalink
Browse files

Implement <&, with test.

Fixes #20.
  • Loading branch information...
Andy Chu
Andy Chu committed Jul 30, 2017
1 parent 2878392 commit 24b951330cd77b8b488c080cb65e8d5ae0f61b93
Showing with 18 additions and 3 deletions.
  1. +6 −3 core/process.py
  2. +12 −0 spec/redirect.test.sh
View
@@ -123,11 +123,14 @@ def _ApplyRedirect(self, r, waiter):
self._PushClose(target_fd)
elif r.tag == redirect_e.DescRedirect:
if r.op_id == Id.Redir_GreatAnd: # 1>&
if r.op_id == Id.Redir_GreatAnd: # 1>&2
if not self._PushDup(r.target_fd, r.fd):
ok = False
elif r.op_id == Id.Redir_LessAnd: # 0<&5
# The only difference between >& and <& is the default file
# descriptor argument.
if not self._PushDup(r.target_fd, r.fd):
ok = False
elif r.op_id == Id.Redir_LessAnd:
raise NotImplementedError
else:
raise NotImplementedError
View
@@ -1,5 +1,17 @@
#!/usr/bin/env bash
### >&
echo hi 1>&2
# stderr: hi
### <&
# Is there a simpler test case for this?
echo foo > $TMP/lessamp.txt
exec 5< $TMP/lessamp.txt
read line <&5
echo "[$line]"
# stdout: [foo]
### Leading redirect
echo hello >$TMP/hello.txt # temporary fix
<$TMP/hello.txt cat

0 comments on commit 24b9513

Please sign in to comment.