Is My Bash Script Too Slow?

0
6
Asked By CuriousCoder42 On

Hey everyone! I'm not really a coder, but I had some fun writing a fetch script with a scroll effect. You can check it out here: [https://codeberg.org/ldm/scr0ll]. I shared it on r/unixporn, but some folks commented that it's running slow. I'm wondering if this slowness is due to poorly written code, the limitations of Bash itself, or if there's a way to optimize the script. Any insights?

2 Answers

Answered By TechieTricks On

When people complain about Bash being slow, it's usually because of how the script is written. For example, using `sleep 0.002` in a tight loop can definitely make things laggy. Bash isn't great for precision tasks like this, but you might want to try using `read -t 0.002` instead of sleep to see if that helps.

Answered By ShellSavvy On

In general, Unix-like shells are slower compared to other languages, especially for graphical tasks in the terminal. While more advanced shells like BASH and ZSH offer better performance due to enhanced tools, there's still a learning curve. But don't worry, I believe you can definitely make it run faster. I'll look more into your code when I can!

CuriousCoder42 -

Thanks! The script was faster at first, but then I had to manage ANSI formatting and it started to slow down.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.