Nope, I don't know why
select(0) redirects to
STDERR (as «
python --version »). Though, you can avoid this by redirecting
select(0)'s file descriptor 2 to file descriptor 1.
Also, you should never use
eval(0), and
set(0) in this case is useless : you're not writing for
POSIX sh, so use arrays ! They're your friends.
Here is how I would write your code :
Code:
#!/bin/bash
exec 2>"$0".errlog
date
lshlsfh
PS3='Option: '
opts=('option 1' quit)
select opt in "${opts[@]}"; do
case "$opt" in
"${opts[0]}") printf 'you selected option 1\n' ;;
"${opts[1]}") printf 'you selected quit\n'
esac
break
done 2>&1
exec 2>&-