{"id":7189,"date":"2008-04-22T22:39:57","date_gmt":"2008-04-22T12:39:57","guid":{"rendered":"http:\/\/michael.ellerman.id.au\/blog\/2008\/04\/22\/bashisms\/"},"modified":"2008-04-22T22:39:57","modified_gmt":"2008-04-22T12:39:57","slug":"bashisms","status":"publish","type":"post","link":"https:\/\/michael.ellerman.id.au\/blog\/2008\/04\/22\/bashisms\/","title":{"rendered":"Bashisms"},"content":{"rendered":"<p>A while back I spent quite a bit of time writing <a href=\"http:\/\/en.wikipedia.org\/wiki\/Korn_shell\">Korn Shell<\/a> scripts, but it was a <em>while<\/em> back. The last few years it&#8217;s been all <a href=\"http:\/\/en.wikipedia.org\/wiki\/Bash\">Bash<\/a> for me, in fact these days I try to write everything in Python.<\/p>\n<p>Anyway that means that just now trying to write a POSIX Shell script has proved a little challenging.<\/p>\n<p>The <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/mindex.html\">manual<\/a> is rather long and wordy, although it seems like it&#8217;s all there. There&#8217;s the <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/utilities\/xcu_chap02.html\">Shell Command Language<\/a>, although things you think of as being part of the shell don&#8217;t seem to be &#8211; ie. &#8220;test&#8221;, which implements the &#8220;[&#8221; in &#8220;if [ x = y ]&#8221;, that&#8217;s <a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/utilities\/test.html\">separate<\/a>.<\/p>\n<p>Despite a bit of googling I couldn&#8217;t find a good list of bashisms and their POSIX replacements, there&#8217;s a few mentioned <a href=\"https:\/\/wiki.ubuntu.com\/DashAsBinSh\">here<\/a>. I did find the next better thing, a script that checks for you, &#8220;checkbashisms&#8221;, it&#8217;s in the Debian <a href=\"http:\/\/packages.debian.org\/devscripts\">devscripts<\/a> package.<\/p>\n<p>And if you&#8217;re running Ubuntu you can switch to using \/bin\/dash for your script temporarily, if it runs under dash it&#8217;s probably pretty safe. Let&#8217;s be honest most people use bash anyway \ud83d\ude42<\/p>\n<p>If anyone does have a good list of bashisms I&#8217;d love to see it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while back I spent quite a bit of time writing Korn Shell scripts, but it was a while back. The last few years it&#8217;s been all Bash for me, in fact these days I try to write everything in Python. Anyway that means that just now trying to write a POSIX Shell script has [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[17,56,57],"_links":{"self":[{"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/posts\/7189"}],"collection":[{"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/comments?post=7189"}],"version-history":[{"count":0,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/posts\/7189\/revisions"}],"wp:attachment":[{"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/media?parent=7189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/categories?post=7189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michael.ellerman.id.au\/blog\/wp-json\/wp\/v2\/tags?post=7189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}