diff --git a/builtin/io_ysh.py b/builtin/io_ysh.py index 38806e1075..95a71bdc4d 100644 --- a/builtin/io_ysh.py +++ b/builtin/io_ysh.py @@ -192,7 +192,7 @@ def Run(self, cmd_val): if action == 'frame_vars_': # Print names in current frame, for testing top = self.mem.var_stack[-1] - print('\tframe_vars_: %s' % ' '.join(top.keys())) + print(' [frame_vars_] %s' % ' '.join(top.keys())) return 0 if action == 'gc-stats_': diff --git a/frontend/py_readline.py b/frontend/py_readline.py index 9bc0437aba..dc092bf547 100644 --- a/frontend/py_readline.py +++ b/frontend/py_readline.py @@ -102,3 +102,16 @@ def MaybeGetReadline(): return Readline() return None + + +if __name__ == '__main__': + import sys + line_input = MaybeGetReadline() + try: + prompt_str = sys.argv[1] + except IndexError: + prompt_str = '! ' + + while True: + x = line_input.prompt_input(prompt_str) + print(x) diff --git a/spec/ysh-builtin-eval.test.sh b/spec/ysh-builtin-eval.test.sh index d99058d735..a299fe2e1a 100644 --- a/spec/ysh-builtin-eval.test.sh +++ b/spec/ysh-builtin-eval.test.sh @@ -1,7 +1,7 @@ # YSH specific features of eval ## our_shell: ysh -## oils_failures_allowed: 4 +## oils_failures_allowed: 3 #### Eval does not take a literal block - can restore this later @@ -398,10 +398,6 @@ pp test_ (_error) #### Dict (&d) { ... } converts frame to dict -# pframe is a read-only parent frame -# -# I guess we have a value.Frame() wrapper then? Why not ... - proc Dict ( ; out; ; block) { var d = io->evalToDict(block) call out->setValue(d) @@ -420,7 +416,7 @@ Dict (&d) { # this is confusing # because it doesn't find it in the local stack frame # it doesn't have 'var without setvar' bug - setvar k2 = 'k2-block' # this is in the dict! It'slocal to! + setvar k2 = 'k2-block' # global, so not checked setvar k3 = 'k3' # do we allow this? @@ -439,7 +435,7 @@ proc p { setvar k = 'k-proc-mutated' # is this in the dict? - setvar k2 = 'k2-proc' # this is in the dict! It'slocal to! + setvar k2 = 'k2-proc' # local, so it's checked } } @@ -499,17 +495,26 @@ proc Dict ( ; out; ; block) { call out->setValue(d) } -var outer = 'xx' +var g = 'xx' Dict (&d) { - setglobal outer = 'zz' + setglobal g = 'zz' + + a = 42 + pp frame_vars_ } +echo pp test_ (d) -echo outer=$outer +echo g=$g +#pp frame_vars_ ## STDOUT: + [frame_vars_] __rear__ a + +(Dict) {"a":42} +g=zz ## END #### bindings created shvar persist, which is different than evalToDict() diff --git a/test/bugs.sh b/test/bugs.sh index 3340c281f7..b400ab3e24 100755 --- a/test/bugs.sh +++ b/test/bugs.sh @@ -206,4 +206,8 @@ bug-2078() { } | _bin/cxx-asan/ysh } +py-readline() { + PYTHONPATH=.:vendor python2 frontend/py_readline.py "$@" +} + "$@"