Tôi có đoạn mã sau bên trong một Makefile:Makefile - Tại sao lệnh đọc không đọc đầu vào của người dùng?
# Root Path
echo "What is the root directory of your webserver? Eg. ~/Server/htdocs" ;
read root_path ;
echo $root_path ;
if [ ! -d $root_path ] ; then \
echo "Error: Could not find that location!" ; exit 1 ; \
fi
Tuy nhiên khi gõ bất cứ điều gì (. Ví dụ: "asd") đây là những gì được trả về:
What is the root directory of your webserver? Eg. ~/Server/htdocs
asd
oot_path
Error: Could not find that location!
Khi những gì tôi mong đợi để xem sẽ be:
What is the root directory of your webserver? Eg. ~/Server/htdocs
asd
asd
Error: Could not find that location!
Làm cách nào để khắc phục sự cố này ???
Bỏ phiếu cho câu hỏi này bởi vì tôi cho rằng nó có thể xuất hiện nhiều lần, nhưng xem Greg, John và Daenyth nói gì về việc thực hiện việc này: * kẻ giết người rìu tiếp theo duy trì mã của bạn sẽ ** không ** thích nó. * – dmckee