<story><title>Use long flags when scripting</title><url>http://thechangelog.com/use-long-flags-when-scripting/</url></story><parent_chain><item><author>npsimons</author><text>While it is generally a good idea to write readable code, it is also true that long flags are not universally supported, and the short flags don&apos;t always have the same meanings (or even exist!) across different systems.&lt;p&gt;This is an interesting conundrum. As has been pointed out, POSIX specifies standard options (which are all short):&lt;p&gt;&lt;a href=&quot;http://news.ycombinator.com/item?id=5165058&quot; rel=&quot;nofollow&quot;&gt;http://news.ycombinator.com/item?id=5165058&lt;/a&gt;&lt;p&gt;But these are not universally supported:&lt;p&gt;&lt;a href=&quot;http://unixhelp.ed.ac.uk/CGI/man-cgi?ps&quot; rel=&quot;nofollow&quot;&gt;http://unixhelp.ed.ac.uk/CGI/man-cgi?ps&lt;/a&gt;&lt;p&gt;What to do? My proposal: do what we do in the C/C++ world when presented with portability problems: abstract it away. POSIX sh supports functions, which can be named appropriately for readability, while calling the proper arguments and commands for different platforms. To avoid unnecessary duplication of platform/argument detection, setup could be done in a function called before anything else to create variables with the appropriate command names and arguments.&lt;p&gt;This may all seem too involved, but realize that we are talking about creating robust software that is to be maintained, so applying proper software engineering principles seems appropriate.</text></item></parent_chain><comment><author>jsaxton86</author><text>A much simpler solution is to comment your code:&lt;p&gt;# Invoke curl in silent mode (-s), pipe the output to grep&lt;p&gt;# and use an extended regex (-E) to only show the resulting&lt;p&gt;# digits (-o: only print matching text, not the whole line):&lt;p&gt;curl -s checkip.dyndns.org | grep -Eo &apos;[0-9\.]+&apos;</text></comment>
<story><title>Use long flags when scripting</title><url>http://thechangelog.com/use-long-flags-when-scripting/</url></story><parent_chain><item><author>npsimons</author><text>While it is generally a good idea to write readable code, it is also true that long flags are not universally supported, and the short flags don&apos;t always have the same meanings (or even exist!) across different systems.&lt;p&gt;This is an interesting conundrum. As has been pointed out, POSIX specifies standard options (which are all short):&lt;p&gt;&lt;a href=&quot;http://news.ycombinator.com/item?id=5165058&quot; rel=&quot;nofollow&quot;&gt;http://news.ycombinator.com/item?id=5165058&lt;/a&gt;&lt;p&gt;But these are not universally supported:&lt;p&gt;&lt;a href=&quot;http://unixhelp.ed.ac.uk/CGI/man-cgi?ps&quot; rel=&quot;nofollow&quot;&gt;http://unixhelp.ed.ac.uk/CGI/man-cgi?ps&lt;/a&gt;&lt;p&gt;What to do? My proposal: do what we do in the C/C++ world when presented with portability problems: abstract it away. POSIX sh supports functions, which can be named appropriately for readability, while calling the proper arguments and commands for different platforms. To avoid unnecessary duplication of platform/argument detection, setup could be done in a function called before anything else to create variables with the appropriate command names and arguments.&lt;p&gt;This may all seem too involved, but realize that we are talking about creating robust software that is to be maintained, so applying proper software engineering principles seems appropriate.</text></item></parent_chain><comment><author>webreac</author><text>I think you fail on two software engineering principles:&lt;p&gt;* &lt;a href=&quot;http://en.wikipedia.org/wiki/KISS_principle&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/KISS_principle&lt;/a&gt;&lt;p&gt;* you should adapt the way you think about programming to the language you are using. This is shell, not Ada.</text></comment>