{"id":970,"date":"2017-11-01T14:47:48","date_gmt":"2017-11-01T19:47:48","guid":{"rendered":"http:\/\/www.ashleyit.com\/blogs\/brentashley\/?p=970"},"modified":"2017-11-01T14:47:48","modified_gmt":"2017-11-01T19:47:48","slug":"effective-script-naming","status":"publish","type":"post","link":"https:\/\/ashleyit.com\/blogs\/brentashley\/2017\/11\/01\/effective-script-naming\/","title":{"rendered":"Effective Script Naming"},"content":{"rendered":"<p><strong>The Task: <\/strong><\/p>\n<p>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.<\/p>\n<p><strong>The Script:<\/strong><\/p>\n<pre>\r\n<code language=bash>#!\/bin\/sh\r\n# $1 is the path to search\r\nfor file in $(find $1)\r\ndo\r\n  if [ -f $file ]\r\n  then\r\n    if [ ! -x $file ]\r\n    then\r\n      head -n 1 $file | egrep \"^#!\" >\/dev\/null 2>&1\r\n      if [ $? = 0 ]\r\n      then\r\n        echo $file\r\n      fi\r\n    fi\r\n  fi\r\ndone\r\n<\/code>\r\n<\/pre>\n<p><strong>Naming the script<\/strong><br \/>\nThere is only one name for a script whose entire purpose is to generate a list of weak ineffective shebangs: <strong><a href=\"http:\/\/williamhung.net\">whung<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-970","post","type-post","status-publish","format-standard","hentry","category-blather"],"_links":{"self":[{"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/posts\/970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/comments?post=970"}],"version-history":[{"count":7,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/posts\/970\/revisions"}],"predecessor-version":[{"id":977,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/posts\/970\/revisions\/977"}],"wp:attachment":[{"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/media?parent=970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/categories?post=970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/tags?post=970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}