如何修复此 Bash?

如何修复此 Bash?

你好,你能看看我的 Bash 脚本吗

问题太多:-我输入时下载将立即开始-修复一些代码后我的脚本显示终止

   #!/bin/bash
removelog(){
   if [ -f /tmp/"$pid".txt ];then
       rm /tmp/"$pid".txt
   fi                  #pak kardan log download bara tamiz kari 
}

time_cal(){
                                      #${var/:/*}
                                      #${var#0} aval
                       #${var%0} akhar
   local hour="$1"             #time i ke karbar mide
   local minute="$2"
   hour=${hour#0}
   minute=${minute#0}
   if [ -z "$hour" ];then
       hour="0"
   fi
   if [ -z "$minute" ];then
       minute="0"
   fi

   echo $((hour * 60  + minute))
}
time_online(){
   
   date='date +%H:%M'
   date=${date/:/ }
   sigma_date='time_cal $date'


}
start_time(){
   local date="$1"
   date=${date/:/ }
   sigma_time='time_cal $date'
   time_online
   while [ "$sigma_date" != "$sigma_time" ];do
       echo $((sigma_time - sigma_date )) "Unitl Start"
       sleep 20
       time_online
   done
}
download_aria(){ #$RANDOM or $$ or ps -A
   aria2c -c -x 16 -s 16 -k 1M "$link" #-c=edame -x=chand connection -k= speed har connection
   echo "1" > /tmp/"$pid".txt      #log bara check kardan end_time
}
end_time(){
   local date="$1"
   date=${date/:/ }
   sigma_time='time_cal $date'
   time_online
   while [ "$sigma_date" != "$sigma_time" ];do
           if [ -f /tmp/"$pid".txt ];then
               break
           fi
       sleep 20
       time_online
   done
   killall aria2c
}
Questions(){
   read -p "..." start_time_input
   read -p "..." end_time_input
   read -p "...: " link
}

clear

trap removelog

pid="$$"

while getopts "s:e:l:v" options;do
   case "$options" in
       s)
           start_time_input=${OPTARG} ;;
       e)
           end_time_input=${OPTARG} ;;
       l)
           link=${OPTARG}
           if [ -z "$link" ];then
               echo "NO Link"
               exit
           elif [ ! -z "$link" ];then
               exit
           fi
           ;;
       v)
           echo "Version 0.4 Beta"
           break ;;
   esac
done
Questions
start_time $start_time_input
download_aria &
end_time $end_time_input
exit

相关内容