- 论坛徽章:
- 0
|
#!/bin/sh
#formprog -
# 在该脚本中,制表位被设为4
template="$1" completed="$2" errors=/tmp/formprog$$
myname='basename$0' #该脚本的基名
trap 'rm -f$errors;exit' 0 1 2 15
#逐行读取$template,将已完成的行写入$completed中:
exec 4<&0 #( )
while read label text
do
case "$label" in
?* #第一个单词以冒号结尾;该行完成
case "$text" in
?*) # ( )
echo "$label $text"
echo "$label $text" 1>;&3
;;
*) #自己填充它:
echo -n "$label"
exec 5<&0 #保存template文件描述符;不要关闭!
exec 0<&4 #( )
read ans
exec 0<&5 #( )
case "$ans" in
" " ;; #为空;不做任何操作
*)echo "$label $ans" 1>;&3;;
esac
;;
esac
;;
*)echo"$myname:bad$1 line:'$label $text'" 1>;&2;break;;
esac
done <"temple"2>;$errors 3>;"$completed"
if [-s $errors];then
/bin/cat $errors 1>;&2
echo "$myname:should you remove '$complete' file?" 1>;&2
fi |
|