<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic getopts command not working at expected in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254146#M687664</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;   I am writing a script using getopts, running in "sh" shell HP-UX 11.11. My optstring is like this&lt;BR /&gt;&lt;BR /&gt;   :gru:f:&lt;BR /&gt;&lt;BR /&gt;   However, during script tests, when invoked like this:&lt;BR /&gt;&lt;BR /&gt;   script -g -u -f&lt;BR /&gt;&lt;BR /&gt;   it places the string "-f" in OPTARG variable, instead of detecting the "u" option with missing argument and let OPTARG unset as the help describes it should do.&lt;BR /&gt;&lt;BR /&gt;   Of course I could add extra logic to catch this, but it would be better if the command performed as expected, unless there is something I am missing. Thank you for any comment yo have for me.&lt;BR /&gt;&lt;BR /&gt;Jose Enrique Gonzalez&lt;BR /&gt;Caracas, Venezuela</description>
    <pubDate>Mon, 18 Aug 2008 19:47:04 GMT</pubDate>
    <dc:creator>José Enrique González</dc:creator>
    <dc:date>2008-08-18T19:47:04Z</dc:date>
    <item>
      <title>getopts command not working at expected</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254146#M687664</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;   I am writing a script using getopts, running in "sh" shell HP-UX 11.11. My optstring is like this&lt;BR /&gt;&lt;BR /&gt;   :gru:f:&lt;BR /&gt;&lt;BR /&gt;   However, during script tests, when invoked like this:&lt;BR /&gt;&lt;BR /&gt;   script -g -u -f&lt;BR /&gt;&lt;BR /&gt;   it places the string "-f" in OPTARG variable, instead of detecting the "u" option with missing argument and let OPTARG unset as the help describes it should do.&lt;BR /&gt;&lt;BR /&gt;   Of course I could add extra logic to catch this, but it would be better if the command performed as expected, unless there is something I am missing. Thank you for any comment yo have for me.&lt;BR /&gt;&lt;BR /&gt;Jose Enrique Gonzalez&lt;BR /&gt;Caracas, Venezuela</description>
      <pubDate>Mon, 18 Aug 2008 19:47:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254146#M687664</guid>
      <dc:creator>José Enrique González</dc:creator>
      <dc:date>2008-08-18T19:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: getopts command not working at expected</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254147#M687666</link>
      <description>Can you post your script, show what it actually does and better detail what you expect it to do?</description>
      <pubDate>Mon, 18 Aug 2008 19:53:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254147#M687666</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2008-08-18T19:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: getopts command not working at expected</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254148#M687668</link>
      <description>Hi Jose:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; it places the string "-f" in OPTARG variable, instead of detecting the "u" option with missing argument &lt;BR /&gt;&lt;BR /&gt;I think this is correct.  All that this is checking is that something (an argument or a switch) follows '-u'.  What follows the '-u' in this example is the '-f' string.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 18 Aug 2008 20:08:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254148#M687668</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-18T20:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: getopts command not working at expected</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254149#M687670</link>
      <description>u: means that you want to get an argument.&lt;BR /&gt;So  -u will get -f as a argument data.&lt;BR /&gt;getopts get the arguments sequencially&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-guf will find -g with no arg, and -u with "f" as argument</description>
      <pubDate>Mon, 18 Aug 2008 20:35:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254149#M687670</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2008-08-18T20:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: getopts command not working at expected</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254150#M687671</link>
      <description>Hi (again) Jose:&lt;BR /&gt;&lt;BR /&gt;Another way of looking at this is that 'getopts' helps you parse switches and arguments.  While it "helps" it still requires "help" (i.e. some additional code).&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 18 Aug 2008 21:02:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getopts-command-not-working-at-expected/m-p/4254150#M687671</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-18T21:02:35Z</dc:date>
    </item>
  </channel>
</rss>

