1# $OpenBSD: read.t,v 1.1 2013/12/02 20:39:44 millert Exp $ 2 3# 4# To test: 5# POSIX: 6# - if no -r, \ is escape character 7# - \newline disappear 8# - \<IFS> -> don't break here 9# - \<anything-else> -> <anything-else> 10# - if -r, backslash is not special 11# - if stdin is tty and shell interactive 12# - prompt for continuation if \newline (prompt to stderr) 13# - a here-document isn't terminated after newline ???? 14# - remaining vars set to empty string (not null) 15# - check field splitting 16# - left over fields and their separators assigned to last var 17# - exit status is normally 0 18# - exit status is > 0 on eof 19# - exit status > 0 on error 20# - signals interrupt reads 21# extra: 22# - can't change read-only variables 23# - error if var name bogus 24# - set -o allexport effects read 25# ksh: 26# x check default variable: REPLY 27# - check -p, -s, -u options 28# - check var?prompt stuff 29# - "echo a b | read x y" sets x,y in parent shell (at&t) 30# 31name: read-IFS-1 32description: 33 Simple test, default IFS 34stdin: 35 echo "A B " > IN 36 unset x y z 37 read x y z < IN 38 echo 1: "x[$x] y[$y] z[$z]" 39 echo 1a: ${z-z not set} 40 read x < IN 41 echo 2: "x[$x]" 42expected-stdout: 43 1: x[A] y[B] z[] 44 1a: 45 2: x[A B] 46--- 47 48name: read-ksh-1 49description: 50 If no var specified, REPLY is used 51stdin: 52 echo "abc" > IN 53 read < IN 54 echo "[$REPLY]"; 55expected-stdout: 56 [abc] 57--- 58 59