Looking for Feedback on My PostgreSQL Bash Utility Script

0
3
Asked By CuriousCoder42 On

I've recently written a comprehensive bash script with functions for handling various PostgreSQL database operations, including creating and dropping databases and users. I'm eager to hear your feedback on it! Here's a quick overview of the two main scripts I created: `logger_utils.sh` for logging messages, and `postgres_utils.sh` for database operations. It's my first time working on something this extensive, so any advice on improvements or critiques would be greatly appreciated. What do you think?

5 Answers

Answered By NewbieToBash On

Just a small tip, when you reference your logger script, the line `# shellcheck source=/dev/null` might not be necessary—it’s more of an informational tag and could confuse some users. If it’s not needed, you can simplify that line.

Answered By PostgreSQLWiz On

Just a thought: your scripts seem designed for a desktop environment, but consider that PostgreSQL is often run on servers without a `Desktop` directory. You might want to structure the paths accordingly for a more server-friendly approach.

Answered By BashEnthusiast9 On

I noticed you're using `date +"%Y-%m-%dT%H:%M:%S%z"` for timestamps. You can simplify that with `printf -v timestamp '%(%FT%T%z)T' -1` so it’s a bit cleaner.

SimplicitySeeker -

Or just use `date -Is` for an even simpler approach!

Answered By ShellScriptMaster On

Also, make sure you implement proper error handling in your main functions. Using shell options like `set -e` and defining traps can help catch errors effectively.

Answered By DevGuru101 On

Great job on the script! Just a heads up, for color support, you might want to avoid hardcoding colors like `COLOR_RED='33[0;31m'`. Instead, use `tput` for terminal capabilities to make it more robust across different environments.

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.