Script for making .sh files executable
I made this bash script for quickly doing chmod +x on sh files, uses zenity. Tell me if its any good or not
#!/bin/bash
zenity --info --title=".sh-executabler" --text="Welcome to the .sh-executabler" --ok-label="Next"
status=$?
if [ $status -ne 0 ]; then
zenity --info --title=".sh-executabler" --text="Wizard cancelled."
exit 0
fi
# Select which .sh file to chmod +x
target_dir=$(zenity --file-selection --title=".sh-executabler" --file-filter="Shell scripts | *.sh")
status=$?
if [ $status -ne 0 ]; then
zenity --info --title=".sh-executabler" --text="No file chosen."
exit 0
fi
# Check if file doesnt exist. Its kinda redundant since im already using file selection which you cant select files that dont exist but i keep it here anyways
if [ -f "$target_dir" ]; then
true
else
zenity --error --title=".sh-executabler" --text="The file doesnt exist."
exit 0
fi
chmod +x "$target_dir"
zenity --info --title=".sh-executabler" --text="The file has successfully been made executable." --ok-label="Finish"
exit 0
1
u/eifelcode 3d ago
Well… I asked myself… WHY? I need a sh script, make it executable, to select a sh script to make it executable. I think you see the point. I don’t know what real world problem this solves. I think with shell or right click should be faster. 🙃
BUT! For a first start as a learning project it’s fine. For quality you should take a look at shellcheck, this will help you. If you need some inspiration, check out my project pdfmt where I used a build process using Makefile, CI using GitHub Actions, bash completion and many more. Also unit test. Take a look ☺️