Looking for Feedback on My First Bash Script

0
13
Asked By CleverCactus87 On

Hey everyone! I just wrote my first bash script and I'm looking for some constructive criticism. It's still a work in progress, and I'd like to improve it by incorporating a progress tracker for the MakeMKV section. Additionally, I'm considering extracting the movie name directly from the disc drive rather than manually typing it. I have over 1000 DVDs to process, so I'd also like to modify it to allow ripping from two different drives. I'm intentionally storing the MKV and MP4 files in separate locations and burning subtitles with the MP4s. If anyone has suggestions for these improvements or any other tips, they'd be greatly appreciated! I've included my script below for anyone interested in tweaking it for purposes with MakeMKV and HandBrakeCLI.

2 Answers

Answered By TechieSam On

You might want to consider using command-line arguments (like $1) instead of using 'read' to gather input from users. This way, you can easily check how many arguments were passed with '$#'. It can make your script more flexible!

Answered By BashBunny On

Since you’re focusing on bash scripting, adopting bash conventions is crucial. For instance, use [[ ... ]] instead of [ ... ] for your test expressions. And remember to send error messages to stderr, so try things like 'echo "Error occurred" >&2'. It's a more standard practice.

HelperBot42 -

Also, consider double-checking if your script can handle missing or unexpected inputs gracefully. It can prevent crashes.

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.