<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mcstafford.com</title>
	<atom:link href="http://mcstafford.com/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://mcstafford.com/blog</link>
	<description>...because the Internet needs another blog</description>
	<lastBuildDate>Thu, 04 Feb 2010 04:47:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>getopts Bash builtin</title>
		<link>http://mcstafford.com/blog/2010/02/02/getopts-bash-builtin</link>
		<comments>http://mcstafford.com/blog/2010/02/02/getopts-bash-builtin#comments</comments>
		<pubDate>Tue, 02 Feb 2010 21:55:10 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mcstafford.com/blog/?p=106</guid>
		<description><![CDATA[getopts facilitates yes/no flags and single-character key/value arguments pairs]]></description>
			<content:encoded><![CDATA[<div>I did not find the output from <code>man builtins</code> all that useful in learning how to use getopts. Fortunately, the <a href="http://bit.ly/94H9WD">Bash Hackers Wiki</a> clicked right away.</div>
<pre>getopts_demo() {
local loop=0 OPTERR=0 optstring=":ab:c:de:"

  echo "# processing getopts ${optstring} on '${@}'"

  while getopts ${optstring} OPT; do
    msg=""
    case ${OPT} in
      \?    )
        msg="failure -${OPTARG} is invalid"; OPTERR=$[${OPTERR}+1];;
      :     )
        msg="failure -${OPTARG} requires a value." OPTERR=$[${OPTERR}+1];;
      a|d   ) msg="success -${OPT} -> ${OPT}flag=1";;
      b|c|e ) msg="success -${OPT}=${OPTARG}";;
    esac
    loop=$[${loop}+1]
    cat &lt;&lt; EOF
  # loop=${loop}
    OPTIND=${OPTIND:-} OPT=${OPT}
    OPTARG=${OPTARG:-''} OPTERR=${OPTERR:-}
    msg=${msg}
EOF
  done
  return ${OPTERR}
}

set -o nounset
getopts_demo -a -b world -e -f -g -c
echo "# ?=${?}"</pre>
<div>The code above defines and calls a function named getopts_demo. Here&#8217;s the output:</div>
<pre># processing getopts :ab:c:de: on '-a -b world -e -f -g -c'
  # loop=1
    OPTIND=2 OPT=a
    OPTARG='' OPTERR=0
    msg=success -a -> aflag=1
  # loop=2
    OPTIND=4 OPT=b
    OPTARG=world OPTERR=0
    msg=success -b=world
  # loop=3
    OPTIND=6 OPT=e
    OPTARG=-f OPTERR=0
    msg=success -e=-f
  # loop=4
    OPTIND=7 OPT=?
    OPTARG=g OPTERR=1
    msg=failure -g is invalid
  # loop=5
    OPTIND=8 OPT=:
    OPTARG=c OPTERR=2
    msg=failure -c requires a value.
# ?=2</pre>
<div>Make sure to note that loop 3 has an error that goes undetected. It makes no sense that <code>-e=-f</code>. Let me know if you have any questions.</div>
]]></content:encoded>
			<wfw:commentRss>http://mcstafford.com/blog/2010/02/02/getopts-bash-builtin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile blogging, iPads and changing expectations</title>
		<link>http://mcstafford.com/blog/2010/01/27/mobile-blogging-ipads-and-changing-expectations</link>
		<comments>http://mcstafford.com/blog/2010/01/27/mobile-blogging-ipads-and-changing-expectations#comments</comments>
		<pubDate>Thu, 28 Jan 2010 04:44:50 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[blackberry]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://mcstafford.com/blog/?p=102</guid>
		<description><![CDATA[I watched the iPad video on YouTube today. This 2&#8243; x 3&#8243; screen feels even smaller now. I suspect we&#8217;ll get one eventually, instead of a netbook. Especially after my wife gets wind of them.]]></description>
			<content:encoded><![CDATA[<div>I watched the iPad video on YouTube today. This 2&#8243; x 3&#8243; screen feels even smaller now.</div>
<div>I suspect we&#8217;ll get one eventually, instead of a netbook. Especially after my wife gets wind of them.</div>
]]></content:encoded>
			<wfw:commentRss>http://mcstafford.com/blog/2010/01/27/mobile-blogging-ipads-and-changing-expectations/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using named arguments in a bash script</title>
		<link>http://mcstafford.com/blog/2010/01/18/using-named-arguments-in-a-bash-script</link>
		<comments>http://mcstafford.com/blog/2010/01/18/using-named-arguments-in-a-bash-script#comments</comments>
		<pubDate>Tue, 19 Jan 2010 00:07:08 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[named arguments]]></category>
		<category><![CDATA[shell scripts]]></category>

		<guid isPermaLink="false">http://mcstafford.com/blog/?p=93</guid>
		<description><![CDATA[<div>Basic setup:</div>
<pre>set -a nounset
export foo='UNSET' bar='UNSET' zee='UNSET' others=''</pre>

<div>Call it:</div>

<pre>evaluate_arguments --foo 1 --bar x one two</pre>

<div>Examine the results:</div>

<pre>echo "# output: foo='${foo}' bar='${bar}' zee='${zee}' others='${others}'"</pre>

<pre># output: foo='1' bar='x' zee='UNSET' others='one two'</pre>]]></description>
			<content:encoded><![CDATA[<div>Here&#8217;s a quick example that can keep you from tracking which order to use when passing arguments.</div>
<pre>evaluate_arguments() {
  local i=1 k='' v='' is_named=0
  while [[ ${i} -le ${#} ]]; do
    k=$(eval echo $`echo ${i}`)
    [[ "${k:0:2}" = "--" ]] &#038;&#038; k="${k:2}"
    is_named=0
    case "${k}" in
      "foo" | "bar" | "zee" ) is_named=1 ;;
    esac
    if [[ ${is_named} -eq 1 ]]; then
      i=$[${i}+1]
      eval "${k}=$(eval echo $`echo ${i}`)"
    else
      eval "others=\"${others}${k} \""
    fi
    i=$[${i}+1]
  done
  [[ "${others}" != "" ]] \
    &#038;&#038; others="${others:0:$[${#others}-1]}" \
    || others='UNSET'
  return 0
}</pre>
<div>Basic setup:</div>
<pre>set -a nounset
export foo='UNSET' bar='UNSET' zee='UNSET' others=''</pre>
<div>Call it:</div>
<pre>evaluate_arguments --foo 1 --bar x one two</pre>
<div>Examine the results:</div>
<pre>cat &lt;&lt; EOF
# output: foo='${foo}' bar='${bar}' zee='${zee}' others='${others}'
EOF
# output: foo='1' bar='x' zee='UNSET' others='one two'</pre>
]]></content:encoded>
			<wfw:commentRss>http://mcstafford.com/blog/2010/01/18/using-named-arguments-in-a-bash-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CrossLoop Annual MySupport Plan</title>
		<link>http://mcstafford.com/blog/2009/12/27/crossloop-annual-mysupport-plan</link>
		<comments>http://mcstafford.com/blog/2009/12/27/crossloop-annual-mysupport-plan#comments</comments>
		<pubDate>Mon, 28 Dec 2009 05:44:21 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[crossloop]]></category>
		<category><![CDATA[support]]></category>

		<guid isPermaLink="false">http://mcstafford.com/blog/?p=21</guid>
		<description><![CDATA[CrossLoop is offering their unlimited Annual MySupport Plan for $179.99. I&#8217;ve wondered now and then about how much such a thing might be worth.]]></description>
			<content:encoded><![CDATA[<p>CrossLoop is offering their unlimited <a href='http://www.crossloop.com/products/pages/56/crossloop_annual_mysupport_plan'>Annual MySupport Plan</a> for $179.99.</p>
<p>I&#8217;ve wondered now and then about how much such a thing might be worth.</p>
]]></content:encoded>
			<wfw:commentRss>http://mcstafford.com/blog/2009/12/27/crossloop-annual-mysupport-plan/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nice touch, VLC</title>
		<link>http://mcstafford.com/blog/2009/12/23/nice-touch-vlc</link>
		<comments>http://mcstafford.com/blog/2009/12/23/nice-touch-vlc#comments</comments>
		<pubDate>Thu, 24 Dec 2009 05:12:27 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[christmas]]></category>
		<category><![CDATA[holidays]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[vlc]]></category>

		<guid isPermaLink="false">http://mcstafford.com/blog/?p=23</guid>
		<description><![CDATA[I&#8217;m about to watch District 9 and noticed the VLC icon has an amusing twist. - image source]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m about to watch <a href="http://www.imdb.com/title/tt1136608/">District 9</a> and noticed the <a href="http://www.videolan.org/vlc/">VLC</a> icon has an amusing twist.</p>
<p><img src="http://mcstafford.com/blog/wp-content/uploads/2009/12/vlc-christmas-icon.jpg" alt="" title="vlc-christmas-icon" width="122" height="165" class="size-full wp-image-25" /></p>
<p>- <a href="http://matt-cutts.blogspot.com/2008/12/merry-christmas-vlc-player-new-version.html">image source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mcstafford.com/blog/2009/12/23/nice-touch-vlc/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LogMeIn adds &#8220;Express&#8221; beta</title>
		<link>http://mcstafford.com/blog/2009/12/18/logmein-adds-express-beta</link>
		<comments>http://mcstafford.com/blog/2009/12/18/logmein-adds-express-beta#comments</comments>
		<pubDate>Fri, 18 Dec 2009 16:51:23 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[crossloop]]></category>
		<category><![CDATA[logmein]]></category>
		<category><![CDATA[remote control]]></category>

		<guid isPermaLink="false">http://mcstafford.com/blog/?p=13</guid>
		<description><![CDATA[I like the idea of LogMeIn's new Express offering. It may take me closer to one-stop shopping.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://www.crossloop.com/index.jsp">CrossLoop</a> to remotely install the <a href="https://secure.logmein.com/welcome/get_logmein_free/">free version of LogMeIn</a> for a while now. CrossLoop would not be necessary except that one of the restrictions in LogMeIn&#8217;s free version is that the installer is crippled.</p>
<p>So, I like the idea of <a href="https://secure.logmein.com/US/products/express/Default.aspx">LogMeIn&#8217;s new Express</a> offering. It may take me closer to one-stop shopping.</p>
<p>via <a href='http://www.downloadsquad.com/2009/12/14/logmein-express-offers-simple-screen-sharing-solution/'>Download Squad</a>, <a href="http://lifehacker.com/5428451/logmein-express-makes-screensharing-simple">Lifehacker</a></p>
<p>&#8211; update: You might save some time by having your remote users download <a href="https://secure.logmein.com/products/express/Download.aspx">the express client</a> directly.</p>
]]></content:encoded>
			<wfw:commentRss>http://mcstafford.com/blog/2009/12/18/logmein-adds-express-beta/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello</title>
		<link>http://mcstafford.com/blog/2009/12/17/hello</link>
		<comments>http://mcstafford.com/blog/2009/12/17/hello#comments</comments>
		<pubDate>Thu, 17 Dec 2009 22:39:37 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mcstafford.com/blog/?p=9</guid>
		<description><![CDATA[I&#8217;m finally ready to begin. Welcome!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m finally ready to begin. Welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://mcstafford.com/blog/2009/12/17/hello/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
