New -n option for read builtin

Usage: read -n nchars
Reads maximum of nchars characters. If nchars <= 0, there's no limit.
This commit is contained in:
Joseph Tannhuber
2014-08-19 14:28:08 +02:00
committed by Kevin Ballard
parent 677cee44ad
commit 4acea72700
6 changed files with 103 additions and 11 deletions

View File

@@ -75,3 +75,19 @@ print_vars ary
echo '' | read -la ary
print_vars ary
set -le IFS
# read -n tests
echo
echo '# read -n tests'
echo 'testing' | read -n 3 foo
echo $foo
echo 'test' | read -n 10 foo
echo $foo
echo 'test' | read -n 0 foo
echo $foo
echo 'testing' | begin; read -n 3 foo; read -n 3 bar; end
echo $foo
echo $bar
echo 'test' | read -n 1 foo
echo $foo