Skip to content

Commit

Permalink
[spec/ysh-bugs] Test case for issue IFS= read -r issue
Browse files Browse the repository at this point in the history
This is #2012

I'm not sure if can prevent this, but we want a better idiom.  Something
like:

    read --line-raw
    read --line-unbuffered
    read --line-unbuf
    read --line-u
  • Loading branch information
Andy C committed Jun 29, 2024
1 parent 3527ba9 commit b15c7f3
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions spec/ysh-bugs.test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## our_shell: ysh
## oils_failures_allowed: 1
## oils_failures_allowed: 2

#### fastlex: NUL byte not allowed inside char literal #' '

Expand Down Expand Up @@ -111,15 +111,19 @@ type -a returned 1
## END
#### && || with YSH constructs ?
#### Do && || with YSH constructs make sense/
# I guess there's nothing wrong with this?
#
# But I generally feel && || are only for
#
# test --file x && test --file y
var x = []
true && call x->append(42)
false && call x->append(43)
pp line (x)
func amp() {
true && return (42)
}
Expand Down Expand Up @@ -164,3 +168,32 @@ echo status=$?
status=2
status=2
## END
#### proc with IFS= read -r line - dynamic scope - issue #2012
# this is an issue with lack of dynamic scope
# not sure exactly how to handle it ...
# shvar IFS= { read } is our replacement for dynamic scope
proc p {
read -r line
write $line
}
proc p-ifs {
IFS= read -r line
write $line
}
#set -x
echo zz | p
echo yy | p-ifs
## STDOUT:
zz
yy
## END

0 comments on commit b15c7f3

Please sign in to comment.