@@ -49,27 +49,32 @@ WGET_PID=$!
4949echo -e " \nPress 'c' to cancel the download at any time.
5050"
5151
52+ CANCELLED=false
53+
5254# Read single character in a loop
5355while kill -0 " $WGET_PID " 2> /dev/null; do
54- read -rsn1 key
56+ read -rsn1 -t 1 key # Add -t 1 to allow loop to check WGET_PID regularly
5557 if [[ " $key " == " c" ]]; then
5658 kill -9 " $WGET_PID " 2> /dev/null
57-
58- # If the file exists, delete it and show merged message
59+ CANCELLED=true
5960 if [[ -f " $OUTPUT " ]]; then
6061 rm -f " $OUTPUT "
61- echo -e " \nDownload cancelled and partial file deleted."
62+ echo -e " \n❌ Download cancelled — partial file deleted."
6263 else
63- echo -e " \nDownload cancelled."
64+ echo -e " \n❌ Download cancelled."
6465 fi
65-
6666 break
6767 fi
6868done
6969
7070# Wait to suppress possible "terminated" messages
7171wait " $WGET_PID " 2> /dev/null
7272
73+ if [[ " $CANCELLED " == false ]]; then
74+ echo -e " \n✅ Download complete!"
75+ sleep 2 # Optional pause to show success message
76+ fi
77+
7378 cd /root
7479 clear
7580 ;;
@@ -91,27 +96,32 @@ WGET_PID=$!
9196echo -e " \nPress 'c' to cancel the download at any time.
9297"
9398
99+ CANCELLED=false
100+
94101# Read single character in a loop
95102while kill -0 " $WGET_PID " 2> /dev/null; do
96- read -rsn1 key
103+ read -rsn1 -t 1 key # Add -t 1 to allow loop to check WGET_PID regularly
97104 if [[ " $key " == " c" ]]; then
98105 kill -9 " $WGET_PID " 2> /dev/null
99-
100- # If the file exists, delete it and show merged message
106+ CANCELLED=true
101107 if [[ -f " $OUTPUT " ]]; then
102108 rm -f " $OUTPUT "
103- echo -e " \nDownload cancelled and partial file deleted."
109+ echo -e " \n❌ Download cancelled — partial file deleted."
104110 else
105- echo -e " \nDownload cancelled."
111+ echo -e " \n❌ Download cancelled."
106112 fi
107-
108113 break
109114 fi
110115done
111116
112117# Wait to suppress possible "terminated" messages
113118wait " $WGET_PID " 2> /dev/null
114119
120+ if [[ " $CANCELLED " == false ]]; then
121+ echo -e " \n✅ Download complete!"
122+ sleep 2 # Optional pause to show success message
123+ fi
124+
115125 cd /root
116126 clear
117127 ;;
@@ -133,27 +143,32 @@ WGET_PID=$!
133143echo -e " \nPress 'c' to cancel the download at any time.
134144"
135145
146+ CANCELLED=false
147+
136148# Read single character in a loop
137149while kill -0 " $WGET_PID " 2> /dev/null; do
138- read -rsn1 key
150+ read -rsn1 -t 1 key # Add -t 1 to allow loop to check WGET_PID regularly
139151 if [[ " $key " == " c" ]]; then
140152 kill -9 " $WGET_PID " 2> /dev/null
141-
142- # If the file exists, delete it and show merged message
153+ CANCELLED=true
143154 if [[ -f " $OUTPUT " ]]; then
144155 rm -f " $OUTPUT "
145- echo -e " \nDownload cancelled and partial file deleted."
156+ echo -e " \n❌ Download cancelled — partial file deleted."
146157 else
147- echo -e " \nDownload cancelled."
158+ echo -e " \n❌ Download cancelled."
148159 fi
149-
150160 break
151161 fi
152162done
153163
154164# Wait to suppress possible "terminated" messages
155165wait " $WGET_PID " 2> /dev/null
156166
167+ if [[ " $CANCELLED " == false ]]; then
168+ echo -e " \n✅ Download complete!"
169+ sleep 2 # Optional pause to show success message
170+ fi
171+
157172 cd /root
158173 clear
159174 ;;
@@ -175,27 +190,32 @@ WGET_PID=$!
175190echo -e " \nPress 'c' to cancel the download at any time.
176191"
177192
193+ CANCELLED=false
194+
178195# Read single character in a loop
179196while kill -0 " $WGET_PID " 2> /dev/null; do
180- read -rsn1 key
197+ read -rsn1 -t 1 key # Add -t 1 to allow loop to check WGET_PID regularly
181198 if [[ " $key " == " c" ]]; then
182199 kill -9 " $WGET_PID " 2> /dev/null
183-
184- # If the file exists, delete it and show merged message
200+ CANCELLED=true
185201 if [[ -f " $OUTPUT " ]]; then
186202 rm -f " $OUTPUT "
187- echo -e " \nDownload cancelled and partial file deleted."
203+ echo -e " \n❌ Download cancelled — partial file deleted."
188204 else
189- echo -e " \nDownload cancelled."
205+ echo -e " \n❌ Download cancelled."
190206 fi
191-
192207 break
193208 fi
194209done
195210
196211# Wait to suppress possible "terminated" messages
197212wait " $WGET_PID " 2> /dev/null
198213
214+ if [[ " $CANCELLED " == false ]]; then
215+ echo -e " \n✅ Download complete!"
216+ sleep 2 # Optional pause to show success message
217+ fi
218+
199219 cd /root
200220 clear
201221 ;;
@@ -217,27 +237,32 @@ WGET_PID=$!
217237echo -e " \nPress 'c' to cancel the download at any time.
218238"
219239
240+ CANCELLED=false
241+
220242# Read single character in a loop
221243while kill -0 " $WGET_PID " 2> /dev/null; do
222- read -rsn1 key
244+ read -rsn1 -t 1 key # Add -t 1 to allow loop to check WGET_PID regularly
223245 if [[ " $key " == " c" ]]; then
224246 kill -9 " $WGET_PID " 2> /dev/null
225-
226- # If the file exists, delete it and show merged message
247+ CANCELLED=true
227248 if [[ -f " $OUTPUT " ]]; then
228249 rm -f " $OUTPUT "
229- echo -e " \nDownload cancelled and partial file deleted."
250+ echo -e " \n❌ Download cancelled — partial file deleted."
230251 else
231- echo -e " \nDownload cancelled."
252+ echo -e " \n❌ Download cancelled."
232253 fi
233-
234254 break
235255 fi
236256done
237257
238258# Wait to suppress possible "terminated" messages
239259wait " $WGET_PID " 2> /dev/null
240260
261+ if [[ " $CANCELLED " == false ]]; then
262+ echo -e " \n✅ Download complete!"
263+ sleep 2 # Optional pause to show success message
264+ fi
265+
241266 cd /root
242267 clear
243268 ;;
@@ -259,27 +284,32 @@ WGET_PID=$!
259284echo -e " \nPress 'c' to cancel the download at any time.
260285"
261286
287+ CANCELLED=false
288+
262289# Read single character in a loop
263290while kill -0 " $WGET_PID " 2> /dev/null; do
264- read -rsn1 key
291+ read -rsn1 -t 1 key # Add -t 1 to allow loop to check WGET_PID regularly
265292 if [[ " $key " == " c" ]]; then
266293 kill -9 " $WGET_PID " 2> /dev/null
267-
268- # If the file exists, delete it and show merged message
294+ CANCELLED=true
269295 if [[ -f " $OUTPUT " ]]; then
270296 rm -f " $OUTPUT "
271- echo -e " \nDownload cancelled and partial file deleted."
297+ echo -e " \n❌ Download cancelled — partial file deleted."
272298 else
273- echo -e " \nDownload cancelled."
299+ echo -e " \n❌ Download cancelled."
274300 fi
275-
276301 break
277302 fi
278303done
279304
280305# Wait to suppress possible "terminated" messages
281306wait " $WGET_PID " 2> /dev/null
282307
308+ if [[ " $CANCELLED " == false ]]; then
309+ echo -e " \n✅ Download complete!"
310+ sleep 2 # Optional pause to show success message
311+ fi
312+
283313 cd /root
284314 clear
285315 ;;
@@ -302,27 +332,32 @@ WGET_PID=$!
302332echo -e " \nPress 'c' to cancel the download at any time.
303333"
304334
335+ CANCELLED=false
336+
305337# Read single character in a loop
306338while kill -0 " $WGET_PID " 2> /dev/null; do
307- read -rsn1 key
339+ read -rsn1 -t 1 key # Add -t 1 to allow loop to check WGET_PID regularly
308340 if [[ " $key " == " c" ]]; then
309341 kill -9 " $WGET_PID " 2> /dev/null
310-
311- # If the file exists, delete it and show merged message
342+ CANCELLED=true
312343 if [[ -f " $OUTPUT " ]]; then
313344 rm -f " $OUTPUT "
314- echo -e " \nDownload cancelled and partial file deleted."
345+ echo -e " \n❌ Download cancelled — partial file deleted."
315346 else
316- echo -e " \nDownload cancelled."
347+ echo -e " \n❌ Download cancelled."
317348 fi
318-
319349 break
320350 fi
321351done
322352
323353# Wait to suppress possible "terminated" messages
324354wait " $WGET_PID " 2> /dev/null
325355
356+ if [[ " $CANCELLED " == false ]]; then
357+ echo -e " \n✅ Download complete!"
358+ sleep 2 # Optional pause to show success message
359+ fi
360+
326361 cd /root
327362 clear
328363 ;;
0 commit comments