当用户想关闭它时,从bash脚本退出STDIN
  我从bash脚本自动创建文件。  我生成了一个文件rc_notes.txt ,它具有来自两个标签的提交消息,并希望将其作为rc_device.txt重新写入一个新文件。 
  我希望用户编写客户发布说明并退出终端中提示的BASH STDIN 。 
我的脚本中的问题是我无法捕捉文件的结尾。
  想知道如何去做。  我不想陷入关闭信号。  我想输入魔术字符串的例子: Done或一些字符串,触发STDIN的关闭,优雅退出脚本。 
我的脚本:
#/bin/bash
set -e
echo "Creating the release candiate text"
rc_file=rc_updater_notes.txt
echo "=========Reading the released commit message file=========="
cat $rc_file
echo "=========End of the commit message file=========="
echo "Now write the release notes"
#exec  < /dev/tty
while read line
do
  echo "$line"
done < "${1:-/dev/stdin}" > rc_file.txt
  它确实创建了文件,但我需要通过输入ctrl+D或ctrl+z手动退出。  我不想这样做。  有什么建议么? 
输入“完成”时打破循环
while read line
do
    if [[ $line = Done ]]; then
        break;
    fi
    echo "$line"
done < "${1:-/dev/stdin}" > rc_file.txt
要么
while read line && [[ $line != Done ]]
do
    echo "$line"
done < "${1:-/dev/stdin}" > rc_file.txt
                        链接地址: http://www.djcxy.com/p/42707.html
                        上一篇: exit from STDIN from bash script when the user want to close it
