Archive for November, 2017

h1

Effective Script Naming

Wednesday, November 1st, 2017

The Task:

Find all scripts in a directory tree that contain a shebang (the first line of the script starts with a #! comment to tell it how to execute it), but the script is not set as executable, meaning the shebang is ineffective.

The Script:

#!/bin/sh
# $1 is the path to search
for file in $(find $1)
do
  if [ -f $file ]
  then
    if [ ! -x $file ]
    then
      head -n 1 $file | egrep "^#!" >/dev/null 2>&1
      if [ $? = 0 ]
      then
        echo $file
      fi
    fi
  fi
done

Naming the script
There is only one name for a script whose entire purpose is to generate a list of weak ineffective shebangs: whung