{"id":7097,"date":"2014-05-20T00:58:13","date_gmt":"2014-05-20T00:58:13","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/20\/cygwin-error-when-doing-ifthenfi-bash-script-collection-of-common-programming-errors\/"},"modified":"2014-05-20T00:58:13","modified_gmt":"2014-05-20T00:58:13","slug":"cygwin-error-when-doing-ifthenfi-bash-script-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/20\/cygwin-error-when-doing-ifthenfi-bash-script-collection-of-common-programming-errors\/","title":{"rendered":"Cygwin error when doing if&hellip;then&hellip;fi &#8211; Bash script-Collection of common programming errors"},"content":{"rendered":"<p>I just started bash shell programming. I have installed Cygwin on my Windows 7 computer. I started writing a script using this tutorial. My script requires an argument to be passed to it, if it doesn&#8217;t it should display an error message. This is the code directly from the tutorial and the same one in my code:<\/p>\n<pre><code>[ $# -eq 0 ] &amp;&amp; { echo \"usage: someArgument\";  exit 1; }\n<\/code><\/pre>\n<p>When I do the following:<\/p>\n<pre><code>sh .\/myscript.sh\n<\/code><\/pre>\n<p>it gives me this error:<\/p>\n<pre><code>-bash: \/home\/Me\/myscript.sh: line 5: syntax error: unexpected end of file\n<\/code><\/pre>\n<p>&#8220;Unexpected end of file&#8221; means I have missed a <code>fi<\/code> or <code>done<\/code>, etc. somewhere.<\/p>\n<p>I double-checked my code, but found <em>nothing<\/em>. Plus, when I comment out the line the script works perfectly fine.<\/p>\n<p>I tried using a <code>if...then...fi<\/code>:<\/p>\n<pre><code>if [ $# -eq 0 ]\nthen\n    echo \"usage: someArgument\"\n    exit 1;\nfi\n<\/code><\/pre>\n<p>but to no avail!<\/p>\n<p>Please help, it&#8217;s been stumping me.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just started bash shell programming. I have installed Cygwin on my Windows 7 computer. I started writing a script using this tutorial. My script requires an argument to be passed to it, if it doesn&#8217;t it should display an error message. This is the code directly from the tutorial and the same one in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7097","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7097","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7097"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7097\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}