<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Some Tips for Shell Code that Won&#8217;t Destroy Your OS</title>
	<atom:link href="http://etbe.coker.com.au/2009/11/20/shell-code-destroy-your-os/feed/" rel="self" type="application/rss+xml" />
	<link>http://etbe.coker.com.au/2009/11/20/shell-code-destroy-your-os/</link>
	<description>Linux, politics, and other interesting things</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:09:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: etbe</title>
		<link>http://etbe.coker.com.au/2009/11/20/shell-code-destroy-your-os/comment-page-1/#comment-25700</link>
		<dc:creator>etbe</dc:creator>
		<pubDate>Fri, 05 Nov 2010 11:13:30 +0000</pubDate>
		<guid isPermaLink="false">http://etbe.coker.com.au/?p=1427#comment-25700</guid>
		<description>http://petereisentraut.blogspot.com/2010/11/pipefail.html

Peter Eisentraut points out that in Bash you can run &quot;set -o pipefail&quot; to handle some failure cases for pipelined commands.</description>
		<content:encoded><![CDATA[<p><a href="http://petereisentraut.blogspot.com/2010/11/pipefail.html" rel="nofollow">http://petereisentraut.blogspot.com/2010/11/pipefail.html</a></p>
<p>Peter Eisentraut points out that in Bash you can run &#8220;set -o pipefail&#8221; to handle some failure cases for pipelined commands.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vk3jed</title>
		<link>http://etbe.coker.com.au/2009/11/20/shell-code-destroy-your-os/comment-page-1/#comment-23408</link>
		<dc:creator>vk3jed</dc:creator>
		<pubDate>Mon, 08 Feb 2010 08:29:12 +0000</pubDate>
		<guid isPermaLink="false">http://etbe.coker.com.au/?p=1427#comment-23408</guid>
		<description>Nice article about shell scripting.  I didn&#039;t consider -e myself, as I tend to use techniques similar to what Louwrentius advocates, sometimes going as far as ensuring the script has been started by the correct user, has all the data it needs to work, and in some cases, is started from the correct place in the filesystem. 

use shell scripting quite a lot, because in my spare time I play around a lot with software that is already 90% shell scripts which manage a few binaries, and there&#039;s no guarantee that the boxes have anything else available (though Perl is usually there and has sometimes been used by others).  The software is also designed to run unattended for months on end, so the scripts have to be able to deal with common situations without intervention, and if they fail, fail gracefully.

However, for quick and dirty scripts, the techniques outlined in the blog post are a good way to avoid too many tears.</description>
		<content:encoded><![CDATA[<p>Nice article about shell scripting.  I didn&#8217;t consider -e myself, as I tend to use techniques similar to what Louwrentius advocates, sometimes going as far as ensuring the script has been started by the correct user, has all the data it needs to work, and in some cases, is started from the correct place in the filesystem. </p>
<p>use shell scripting quite a lot, because in my spare time I play around a lot with software that is already 90% shell scripts which manage a few binaries, and there&#8217;s no guarantee that the boxes have anything else available (though Perl is usually there and has sometimes been used by others).  The software is also designed to run unattended for months on end, so the scripts have to be able to deal with common situations without intervention, and if they fail, fail gracefully.</p>
<p>However, for quick and dirty scripts, the techniques outlined in the blog post are a good way to avoid too many tears.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Louwrentius</title>
		<link>http://etbe.coker.com.au/2009/11/20/shell-code-destroy-your-os/comment-page-1/#comment-22356</link>
		<dc:creator>Louwrentius</dc:creator>
		<pubDate>Sat, 19 Dec 2009 17:24:56 +0000</pubDate>
		<guid isPermaLink="false">http://etbe.coker.com.au/?p=1427#comment-22356</guid>
		<description>Ok, i misunderstood the pov of your article. From your perspective, I agree with the set -e option. 

Also, I understand why people might argue that if you write anything in shell script that would be worth the effort to do it &#039;right&#039;, you might as well do it in a &#039;proper language&#039; such as Python or Ruby for example.

I wrote some bigger stuff in bash, but that&#039;s because I&#039;m just crazy. There is no other reason for it.</description>
		<content:encoded><![CDATA[<p>Ok, i misunderstood the pov of your article. From your perspective, I agree with the set -e option. </p>
<p>Also, I understand why people might argue that if you write anything in shell script that would be worth the effort to do it &#8216;right&#8217;, you might as well do it in a &#8216;proper language&#8217; such as Python or Ruby for example.</p>
<p>I wrote some bigger stuff in bash, but that&#8217;s because I&#8217;m just crazy. There is no other reason for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: etbe</title>
		<link>http://etbe.coker.com.au/2009/11/20/shell-code-destroy-your-os/comment-page-1/#comment-22293</link>
		<dc:creator>etbe</dc:creator>
		<pubDate>Fri, 18 Dec 2009 00:01:54 +0000</pubDate>
		<guid isPermaLink="false">http://etbe.coker.com.au/?p=1427#comment-22293</guid>
		<description>Louwrentius: The thing to keep in mind is that I didn&#039;t write this post for the benefit of skillful people who are capable of coding in the style you advocate, or for people who need to write code that will later be maintained by such people.

Putting &quot;set -e&quot; at the start of a script is easy, simple, and solves many problems.  While it&#039;s not ideal, it will save servers from being trashed on occasion and that&#039;s what really matters.

But your points are good and are useful for anyone who wants to take their scripting to a higher level.</description>
		<content:encoded><![CDATA[<p>Louwrentius: The thing to keep in mind is that I didn&#8217;t write this post for the benefit of skillful people who are capable of coding in the style you advocate, or for people who need to write code that will later be maintained by such people.</p>
<p>Putting &#8220;set -e&#8221; at the start of a script is easy, simple, and solves many problems.  While it&#8217;s not ideal, it will save servers from being trashed on occasion and that&#8217;s what really matters.</p>
<p>But your points are good and are useful for anyone who wants to take their scripting to a higher level.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Louwrentius</title>
		<link>http://etbe.coker.com.au/2009/11/20/shell-code-destroy-your-os/comment-page-1/#comment-22286</link>
		<dc:creator>Louwrentius</dc:creator>
		<pubDate>Thu, 17 Dec 2009 17:27:07 +0000</pubDate>
		<guid isPermaLink="false">http://etbe.coker.com.au/?p=1427#comment-22286</guid>
		<description>Sorry for creating a separate posting, but I want to state that I fully agree with the author, only not on all the solutions. ;)</description>
		<content:encoded><![CDATA[<p>Sorry for creating a separate posting, but I want to state that I fully agree with the author, only not on all the solutions. ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Louwrentius</title>
		<link>http://etbe.coker.com.au/2009/11/20/shell-code-destroy-your-os/comment-page-1/#comment-22285</link>
		<dc:creator>Louwrentius</dc:creator>
		<pubDate>Thu, 17 Dec 2009 17:23:29 +0000</pubDate>
		<guid isPermaLink="false">http://etbe.coker.com.au/?p=1427#comment-22285</guid>
		<description>In my opinion, the set -e option is just a pain and should NEVER be used in a decent shell script. 

I think the set -e option is just an excuse for not writing proper error handling routines and fail safe code.  The &#124;&#124; exit 1 statements seem like an ugly solution to me. 

#!/bin/sh
cd /tmp/whatever &#124;&#124; exit 1
rm -rf *

Could be better written something like:

#!/bin/sh
DIR=/tmp/whatever
if [ -e &quot;$DIR&quot; ] &amp;&amp; [ ! -z &quot;$DIR&quot; ]
then
        rm -rf &quot;$DIR/*&quot;
fi

If you want to run dangerous commands like &#039;rm&#039; you may want to spend the 2 minutes extra to write a &#039;proper&#039; fail safe mechanism instead of using set -e or other simple solutions.

But that is just me.</description>
		<content:encoded><![CDATA[<p>In my opinion, the set -e option is just a pain and should NEVER be used in a decent shell script. </p>
<p>I think the set -e option is just an excuse for not writing proper error handling routines and fail safe code.  The || exit 1 statements seem like an ugly solution to me. </p>
<p>#!/bin/sh<br />
cd /tmp/whatever || exit 1<br />
rm -rf *</p>
<p>Could be better written something like:</p>
<p>#!/bin/sh<br />
DIR=/tmp/whatever<br />
if [ -e "$DIR" ] &amp;&amp; [ ! -z "$DIR" ]<br />
then<br />
        rm -rf &#8220;$DIR/*&#8221;<br />
fi</p>
<p>If you want to run dangerous commands like &#8216;rm&#8217; you may want to spend the 2 minutes extra to write a &#8216;proper&#8217; fail safe mechanism instead of using set -e or other simple solutions.</p>
<p>But that is just me.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

