Skip to content

Commit

Permalink
[test] More repro for Ctrl-R history bug
Browse files Browse the repository at this point in the history
This is issue #2081

It's due to GNU readline horizontal-scroll-mode

Unrelated: cases in spec/builtin-eval-test, with pp frame_vars_
  • Loading branch information
Andy C committed Sep 27, 2024
1 parent 14e91b3 commit 62b57aa
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion builtin/io_ysh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_':
Expand Down
13 changes: 13 additions & 0 deletions frontend/py_readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
25 changes: 15 additions & 10 deletions spec/ysh-builtin-eval.test.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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?
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions test/bugs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,8 @@ bug-2078() {
} | _bin/cxx-asan/ysh
}

py-readline() {
PYTHONPATH=.:vendor python2 frontend/py_readline.py "$@"
}

"$@"

0 comments on commit 62b57aa

Please sign in to comment.