OT: Checking fedora shell script for errors?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Recently, had an issue with firefox script creating a zombie because of an error. They fixed it, but then created another error since missed a space after a [, that was then corrected.

In some emails, learned about shellcheck package..

Have done some testing to check scripts, but just started.
In looking at /usr/bin on my machine, there are just under 5,000 files, but only 488 are shell scripts. So, created a little script that will run against all script files, and create an file with results.

Current version is shellcheck-dir3
#!/usr/bin/bash
if [[ "$1" != "error" && "$1" != "warning" && "$1" != "info" ]] ; then  s=style; else  s="$1"; fi
echo -n "" >/tmp/"$s"-out
for a in ./*; do file "$a" | grep -E '(/ksh script|/dash script|/sh script|Bourne|POSIX)' | cut -f 1 -d: ; done >/tmp/file-list
time while read -r line; do shellcheck -x -W 0 -S"$s" "$line"; done </tmp/file-list >>/tmp/"$s"-out

#create uniq listing of errors found?
grep "\-\- SC" </tmp/"$s"-out | sed 's/.*^//' |sort | uniq > /tmp/"$s"-summary.out
runuser -u $USER gedit /tmp/"$s"-out /tmp/"$s"-summary.out

shellcheck has 4 security levels (error, warning, info, style)
error limits the reports, but gives about 688 lines with /usr/bin.
Each lower level reports more and more suggestions.

Some errors are simple. Number of script the exit -1, but reports that exit values are suppose to be 0-255, so basically the -1 becomes 255. But some look like they might cause real issues.

Just interesting to look out. Originally used a for loop, but ran into some issues, so switch to the while that even handles files that contain spaces.

Thanks for any suggestions.
  
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux