<?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: Command line arguments in bash scripts</title>
	<atom:link href="http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/</link>
	<description>The random things that spew forth from my brain...</description>
	<lastBuildDate>Mon, 16 Jan 2012 18:43:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19620</generator>
	<item>
		<title>By: chilicuil</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-2/#comment-8954</link>
		<dc:creator>chilicuil</dc:creator>
		<pubDate>Wed, 30 Jun 2010 00:02:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-8954</guid>
		<description>Hey dude, thanks a lot for sharing this peace of goodness, I&#039;ve been dealing with getopts and getopt and I still can&#039;t believe how bash has no proper built-in functions to deal with all kind of options. getopts is great, but I really wanna be able to use --long-options. There are a lot of libraries who try to fix this issue but so far this one is the most easy and easy to integrate (I don&#039;t wanna source any other file!) that I&#039;ve found, I wanna focus in my code not in handling options. 
 
Thanks again! :) </description>
		<content:encoded><![CDATA[<p>Hey dude, thanks a lot for sharing this peace of goodness, I&#039;ve been dealing with getopts and getopt and I still can&#039;t believe how bash has no proper built-in functions to deal with all kind of options. getopts is great, but I really wanna be able to use &#8211;long-options. There are a lot of libraries who try to fix this issue but so far this one is the most easy and easy to integrate (I don&#039;t wanna source any other file!) that I&#039;ve found, I wanna focus in my code not in handling options.</p>
<p>Thanks again! <img src='http://blog.apokalyptik.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anonymous</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-1/#comment-8268</link>
		<dc:creator>anonymous</dc:creator>
		<pubDate>Sun, 25 Jan 2009 15:18:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-8268</guid>
		<description>He&#039;s right, y&#039;know. 
 
getopt works quite marvelously, and re-inventing the wheel is pretty retarded. 
 
Six levels of nesting, just to parse parameters looks like a maintainability nightmare, compared to a single, simple while/case loop. </description>
		<content:encoded><![CDATA[<p>He&#039;s right, y&#039;know.</p>
<p>getopt works quite marvelously, and re-inventing the wheel is pretty retarded.</p>
<p>Six levels of nesting, just to parse parameters looks like a maintainability nightmare, compared to a single, simple while/case loop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Toki</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-1/#comment-8001</link>
		<dc:creator>Toki</dc:creator>
		<pubDate>Wed, 10 Dec 2008 13:29:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-8001</guid>
		<description>Thank you:) </description>
		<content:encoded><![CDATA[<p>Thank you:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: apokalyptik</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-1/#comment-7939</link>
		<dc:creator>apokalyptik</dc:creator>
		<pubDate>Tue, 18 Nov 2008 12:24:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-7939</guid>
		<description>@Doug -- Why thanks. I especially appreciate the retarded bit. Cheers! </description>
		<content:encoded><![CDATA[<p>@Doug &#8212; Why thanks. I especially appreciate the retarded bit. Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fabricio</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-1/#comment-7936</link>
		<dc:creator>fabricio</dc:creator>
		<pubDate>Mon, 17 Nov 2008 07:41:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-7936</guid>
		<description>Here&#039;s yet another take on it: 
  &lt;a href=&quot;http://codesnippets.joyent.com/posts/show/1697&quot; rel=&quot;nofollow&quot;&gt;http://codesnippets.joyent.com/posts/show/1697&lt;/a&gt; </description>
		<content:encoded><![CDATA[<p>Here&#039;s yet another take on it:</p>
<p>  <a href="http://codesnippets.joyent.com/posts/show/1697" rel="nofollow">http://codesnippets.joyent.com/posts/show/1697</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-1/#comment-7931</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Thu, 13 Nov 2008 09:55:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-7931</guid>
		<description>This is a pretty retarded and feature-lacking re-invention of the wheel. Seriously: 
 
help getopt; 
 
It&#039;s a bash built-in (and mostly compatible binaries that the built-in was based off of exist on any sane system even without bash!). 
 
Example usage: 
 
# Parse commandline options. 
GETOPT=&quot;$(getopt -o c:olhdfs --long children:,stdout,syslog,help,dry-run,force,status -n &quot;$0&quot; -- &quot;$@&quot;)&quot; 
if [ &quot;$?&quot; -gt &#039;0&#039; ]; then 
  echo &quot;$USAGE&quot; 
  exit 1 
fi 
 
eval set -- &quot;$GETOPT&quot; 
 
while true; do 
  case &quot;$1&quot; in 
    -h&#124;--help) echo &quot;$USAGE&quot;; exit 0 ;; 
    -c&#124;--children) if [ &quot;$2&quot; -gt &#039;0&#039; ] &gt;/dev/null 2&gt;&amp;1; then 
                    MAXCHILDREN=&quot;$2&quot;; 
                    shift; 
                    shift; 
                  else 
                    echo &quot;Number of children MUST be an integer.&quot;; 
                    exit 1; 
                  fi 
                    ;; 
    -o&#124;--stdout) TTYOUT=1; shift ;; 
    -l&#124;--syslog) SYSLOGOUT=1; shift ;; 
    -d&#124;--dry-run) TTYOUT=1; DRYRUN=1; shift ;; 
    -s&#124;--status) TTYOUT=1; STATUSONLY=1; shift ;; 
    -f&#124;--force) FORCE=1; shift ;; 
    --) shift; break ;; 
    *) echo &quot;Invalid Option ${1}.&quot;; echo &quot;$USAGE&quot;; exit 1 ;; 
  esac 
done </description>
		<content:encoded><![CDATA[<p>This is a pretty retarded and feature-lacking re-invention of the wheel. Seriously:</p>
<p>help getopt;</p>
<p>It&#039;s a bash built-in (and mostly compatible binaries that the built-in was based off of exist on any sane system even without bash!).</p>
<p>Example usage:</p>
<p># Parse commandline options.</p>
<p>GETOPT=&quot;$(getopt -o c:olhdfs &#8211;long children:,stdout,syslog,help,dry-run,force,status -n &quot;$0&quot; &#8212; &quot;$@&quot;)&quot;</p>
<p>if [ &quot;$?&quot; -gt &#039;0&#039; ]; then</p>
<p>  echo &quot;$USAGE&quot;</p>
<p>  exit 1</p>
<p>fi</p>
<p>eval set &#8212; &quot;$GETOPT&quot;</p>
<p>while true; do</p>
<p>  case &quot;$1&quot; in</p>
<p>    -h|&#8211;help) echo &quot;$USAGE&quot;; exit 0 ;;</p>
<p>    -c|&#8211;children) if [ &quot;$2&quot; -gt &#039;0&#039; ] &gt;/dev/null 2&gt;&amp;1; then</p>
<p>                    MAXCHILDREN=&quot;$2&quot;;</p>
<p>                    shift;</p>
<p>                    shift;</p>
<p>                  else</p>
<p>                    echo &quot;Number of children MUST be an integer.&quot;;</p>
<p>                    exit 1;</p>
<p>                  fi</p>
<p>                    ;;</p>
<p>    -o|&#8211;stdout) TTYOUT=1; shift ;;</p>
<p>    -l|&#8211;syslog) SYSLOGOUT=1; shift ;;</p>
<p>    -d|&#8211;dry-run) TTYOUT=1; DRYRUN=1; shift ;;</p>
<p>    -s|&#8211;status) TTYOUT=1; STATUSONLY=1; shift ;;</p>
<p>    -f|&#8211;force) FORCE=1; shift ;;</p>
<p>    &#8211;) shift; break ;;</p>
<p>    *) echo &quot;Invalid Option ${1}.&quot;; echo &quot;$USAGE&quot;; exit 1 ;;</p>
<p>  esac</p>
<p>done</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bookmarks about Scripts</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-1/#comment-7910</link>
		<dc:creator>Bookmarks about Scripts</dc:creator>
		<pubDate>Sat, 27 Sep 2008 03:15:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-7910</guid>
		<description>[...] - bookmarked by 1 members originally found by showwhat on 2008-09-09  Command line arguments in bash scripts  http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/ - bookmarked by 6 [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8211; bookmarked by 1 members originally found by showwhat on 2008-09-09  Command line arguments in bash scripts  <a href="http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/" rel="nofollow">http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/</a> &#8211; bookmarked by 6 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bothie</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-1/#comment-7899</link>
		<dc:creator>bothie</dc:creator>
		<pubDate>Fri, 22 Aug 2008 08:03:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-7899</guid>
		<description>&gt;&gt;&gt; For this reason the script should be updates to allow for arguments like &#8220;&#8211;arguments=&#8211;foo&#8221; 
 
Watching closer on the script I discovered, that the script already support that style of arguments. 
 
However, it doesn&#039;t support other things. Imagine 
 
mv -i oldname newname 
 
This would lead to i=oldname and newname -&gt; ??? 
 
In short: This script helps in parsing command line options, but it isn&#039;t the non-plus-ultra yet. 
 
Regards, Bodo </description>
		<content:encoded><![CDATA[<p>&gt;&gt;&gt; For this reason the script should be updates to allow for arguments like &ldquo;&ndash;arguments=&ndash;foo&rdquo;</p>
<p>Watching closer on the script I discovered, that the script already support that style of arguments.</p>
<p>However, it doesn&#039;t support other things. Imagine</p>
<p>mv -i oldname newname</p>
<p>This would lead to i=oldname and newname -&gt; ???</p>
<p>In short: This script helps in parsing command line options, but it isn&#039;t the non-plus-ultra yet.</p>
<p>Regards, Bodo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bothie</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-1/#comment-7898</link>
		<dc:creator>bothie</dc:creator>
		<pubDate>Thu, 21 Aug 2008 06:33:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-7898</guid>
		<description>Oh, and another thing. 
 
@Milian Wolff: 
 
It doesn&#039;t make a difference if you write 
 
run.sh --file &quot;foobar&quot; --arguments &quot;--foo&quot; 
 
or if you write 
 
run.sh --file &quot;foobar&quot; --arguments --foo 
 
For this reason the script should be updates to allow for arguments like &quot;--arguments=--foo&quot; 
 
Regards, Bodo </description>
		<content:encoded><![CDATA[<p>Oh, and another thing.</p>
<p>@Milian Wolff:</p>
<p>It doesn&#039;t make a difference if you write</p>
<p>run.sh &#8211;file &quot;foobar&quot; &#8211;arguments &quot;&#8211;foo&quot;</p>
<p>or if you write</p>
<p>run.sh &#8211;file &quot;foobar&quot; &#8211;arguments &#8211;foo</p>
<p>For this reason the script should be updates to allow for arguments like &quot;&#8211;arguments=&#8211;foo&quot;</p>
<p>Regards, Bodo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bothie</title>
		<link>http://blog.apokalyptik.com/2008/07/07/command-line-arguments-in-bash-scripts/comment-page-1/#comment-7897</link>
		<dc:creator>bothie</dc:creator>
		<pubDate>Thu, 21 Aug 2008 06:30:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.apokalyptik.com/?p=292#comment-7897</guid>
		<description>Two comments: 
 
1. Instead of 
 
	OIFS=$IFS; IFS=$(echo -e &quot;n&quot;); getopt $@; IFS=$OIFS 
 
you could also just write 
 
	getopt &quot;$@&quot; 
 
2. It may be a security problem if the getopt function may write any variable in the normal namespace of the script. So, it&#039;s better to prefix each variable by e.g. &quot;arg_&quot;. So --name bothie won&#039;t get name=&quot;bothie&quot; but arg_name=&quot;bothie&quot;. 
 
Regards, Bodo </description>
		<content:encoded><![CDATA[<p>Two comments:</p>
<p>1. Instead of</p>
<p>	OIFS=$IFS; IFS=$(echo -e &quot;n&quot;); getopt $@; IFS=$OIFS</p>
<p>you could also just write</p>
<p>	getopt &quot;$@&quot;</p>
<p>2. It may be a security problem if the getopt function may write any variable in the normal namespace of the script. So, it&#039;s better to prefix each variable by e.g. &quot;arg_&quot;. So &#8211;name bothie won&#039;t get name=&quot;bothie&quot; but arg_name=&quot;bothie&quot;.</p>
<p>Regards, Bodo</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached
Database Caching 2/18 queries in 0.007 seconds using memcached
Object Caching 352/364 objects using memcached

Served from: blog.apokalyptik.com @ 2012-02-08 17:12:41 -->
