{"id":1085,"date":"2013-10-04T12:29:05","date_gmt":"2013-10-04T12:29:05","guid":{"rendered":"http:\/\/kera.name\/articles\/?p=1085"},"modified":"2013-10-04T12:29:05","modified_gmt":"2013-10-04T12:29:05","slug":"line-endings-and-bash-red-herrings","status":"publish","type":"post","link":"https:\/\/kera.name\/articles\/2013\/10\/line-endings-and-bash-red-herrings\/","title":{"rendered":"Line endings and Bash red herrings"},"content":{"rendered":"<p>It&#039;s just taken a colleague and I a number of hours &mdash; on release day, naturally &mdash; to track down a fault with a shell script, because Bash was unclear in its error reporting:<\/p>\n<pre><code>Performing firmware upgrade...\n.\/v2.14~test.bin: line 172: \/tmp\/upgrade-hw.sh: not found\n[xy765 \/root]# cd \/tmp\n[xy765 \/tmp]# ls -l upgrade-hw.sh\n-rwxrwxr-x    1 503      504          3414 Oct  4 12:09 upgrade-hw.sh<\/code><\/pre>\n<p>The file is obviously not &#034;not found&#034;, but it turned out that <code>upgrade-hw.sh<\/code> had recently been imbued with DOS-type line endings (which affected every line including the first one with the shebang &#034;<code>#!\/bin\/bash<\/code>&#034;) and it was, in fact, the &#034;<code>\/bin\/bash^M<\/code>&#034; program that could not be found!<\/p>\n<p>A lesson to us all&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#039;s just taken a colleague and I a number of hours &mdash; on release day, naturally &mdash; to track down a fault with a shell script, because Bash was unclear in its error reporting.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[74,73,12],"_links":{"self":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/1085"}],"collection":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/comments?post=1085"}],"version-history":[{"count":2,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/1085\/revisions"}],"predecessor-version":[{"id":1087,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/1085\/revisions\/1087"}],"wp:attachment":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/media?parent=1085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/categories?post=1085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/tags?post=1085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}