[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: more bash questions
> I am tring to get a statement where I request input from the user, and
> when a carriage return is entered with no data the script moves to the
> next step. So far I have:
> while read USER; do
> if [ -n $USER ]; then
> echo $USER >> /tmp/allow.users
> echo "Thank you."
> But its not ending when I enter a blank line. I think its because the
> minute the user enters the first bit a requested data, then $USER is not
> null, so the loop will never end.
> I am fairly certain what I want to do is pretty easy, but my first stab is
> not quite there. Can someone point out where to take this?
Well, $USER contains the carriage return, so it's not exactly null.
Replacing the if with [ x"$USER" != "x" ] and adding a ;break to the
thank you line does what you want.
To unsubscribe, send email to firstname.lastname@example.org with
"unsubscribe luci-discuss" in the body.