Permalink
Browse files

Implement a first cut of test -x.

Addresses issue #19.
  • Loading branch information...
Andy Chu
Andy Chu committed Sep 6, 2017
1 parent c57b83e commit 16ca9069d47ef01fd615d861979552dd2643f9bf
Showing with 13 additions and 1 deletion.
  1. +0 −1 core/builtin.py
  2. +4 −0 core/expr_eval.py
  3. +9 −0 spec/test-builtin.test.sh
View
@@ -692,7 +692,6 @@ def Type(argv, funcs, path_val):
return status
def Trap(argv, traps):
# TODO: register trap
View
@@ -488,6 +488,10 @@ def Eval(self, node):
if op_id == Id.BoolUnary_d:
return stat.S_ISDIR(mode)
if op_id == Id.BoolUnary_x:
# TODO: Bash and dash do something more complicated with faccessat()?
return bool(mode & os.X_OK)
raise NotImplementedError(op_id)
if arg_type == OperandType.Str:
@@ -170,3 +170,12 @@ echo status=$?
test -d $TMP/__nonexistent_Z_Z__
echo status=$?
# stdout-json: "status=0\nstatus=1\n"
### -x
rm -f $TMP/x
echo 'echo hi' > $TMP/x
test -x $TMP/x || echo 'no'
chmod +x $TMP/x
test -x $TMP/x && echo 'yes'
test -x $TMP/__nonexistent__ || echo 'bad'
# stdout-json: "no\nyes\nbad\n"

0 comments on commit 16ca906

Please sign in to comment.