<?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 Re: expr stripping off leading zeroes from a string in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155193#M684003</link>
    <description>We've found some additional information.&lt;BR /&gt;This seems to occur when we have UNIX95=XP64 in the environment.  When we unset this, it works correctly.  Now I'm wondering why it doesn't work when UNIX95=XP64.</description>
    <pubDate>Thu, 05 Feb 2009 22:49:04 GMT</pubDate>
    <dc:creator>Paul Maglinger</dc:creator>
    <dc:date>2009-02-05T22:49:04Z</dc:date>
    <item>
      <title>expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155189#M683999</link>
      <description>Using the following:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;x='00545'&lt;BR /&gt;expr substr "$x" 1 2&lt;BR /&gt;&lt;BR /&gt;The above code produces the following output:&lt;BR /&gt;54&lt;BR /&gt;&lt;BR /&gt;Shouldn't it have produced:&lt;BR /&gt;00&lt;BR /&gt;&lt;BR /&gt;Running HP-UX 11.23 on Itanium servers.</description>
      <pubDate>Thu, 05 Feb 2009 21:27:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155189#M683999</guid>
      <dc:creator>Paul Maglinger</dc:creator>
      <dc:date>2009-02-05T21:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155190#M684000</link>
      <description>what does it do in ksh?  &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Feb 2009 21:35:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155190#M684000</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-02-05T21:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155191#M684001</link>
      <description>Same thing.  Tried it on several different shells, no joy.</description>
      <pubDate>Thu, 05 Feb 2009 21:41:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155191#M684001</guid>
      <dc:creator>Paul Maglinger</dc:creator>
      <dc:date>2009-02-05T21:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155192#M684002</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;This returns "00" on an 11.23 Itanium for me:&lt;BR /&gt;&lt;BR /&gt;# cat ./mysh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;x='00545'&lt;BR /&gt;expr substr "$x" 1 2&lt;BR /&gt;&lt;BR /&gt;# ./mysh&lt;BR /&gt;00&lt;BR /&gt;&lt;BR /&gt;# what /bin/sh&lt;BR /&gt;/bin/sh:&lt;BR /&gt;         Version M-11/16/88f&lt;BR /&gt;         $ B.11.23  Aug 22 2007 09:08:12 $&lt;BR /&gt;         builtin.c $Date: 2005/01/19 00:36:04 $Revision: r11.23/5 PATCH_11.23 (PHCO_32444)&lt;BR /&gt;         service.c $Date: 2007/03/06 17:54:39 $Revision: r11.23/3 PATCH_11.23 (PHCO_34129)&lt;BR /&gt;         xec.c $Date: 2005/11/22 04:08:50 $Revision: r11.23/6 PATCH_11.23 (PHCO_34129)&lt;BR /&gt;         emacs.c $Date: 2007/01/05 12:12:17 $Revision: r11.23/4 PATCH_11.23 (PHCO_34129)&lt;BR /&gt;         fault.c $Date: 2007/03/06 17:54:43 $Revision: r11.23/6 PATCH_11.23 (PHCO_34129)&lt;BR /&gt;         history.c $Date: 2007/04/23 15:02:12 $Revision: r11.23/1 PATCH_11.23 (PHCO_36506)&lt;BR /&gt;         io.c $Date: 2007/04/23 15:02:21 $Revision: r11.23/4 PATCH_11.23 (PHCO_36506)&lt;BR /&gt;         jobs.c $Date: 2005/08/10 00:06:06 $Revision: r11.23/5 PATCH_11.23 (PHCO_32444)&lt;BR /&gt;         test.c $Date: 2007/10/12 18:33:56 $Revision: r11.23/2 PATCH_11.23 (PHCO_36506)&lt;BR /&gt;         $Revision: @(#) ksh R11.23_BL2007_1114_1 PATCH_11.23 PHCO_36506&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 05 Feb 2009 22:37:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155192#M684002</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-02-05T22:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155193#M684003</link>
      <description>We've found some additional information.&lt;BR /&gt;This seems to occur when we have UNIX95=XP64 in the environment.  When we unset this, it works correctly.  Now I'm wondering why it doesn't work when UNIX95=XP64.</description>
      <pubDate>Thu, 05 Feb 2009 22:49:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155193#M684003</guid>
      <dc:creator>Paul Maglinger</dc:creator>
      <dc:date>2009-02-05T22:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155194#M684004</link>
      <description>Hi (again) Paul:&lt;BR /&gt;&lt;BR /&gt;Using 11.23 (with current patches) on an rx2660, I can't reproduce this:&lt;BR /&gt;&lt;BR /&gt;# cat ./mysh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;UNIX95=XP64&lt;BR /&gt;x='00545'&lt;BR /&gt;expr substr "$x" 1 2&lt;BR /&gt;&lt;BR /&gt;...which works the same as :&lt;BR /&gt;&lt;BR /&gt;# cat ./mysh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;UNIX95=&lt;BR /&gt;x='00545'&lt;BR /&gt;expr substr "$x" 1 2&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;I would never capriciously set 'UNIX95' unless you are specifically needing it; e.g with 'ps' to enable the '-o' formatting options.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 05 Feb 2009 23:01:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155194#M684004</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-02-05T23:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155195#M684005</link>
      <description>This also fails if you have "typeset -i x", since x would be an integer.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;This seems to occur when we have UNIX95=XP64 in the environment. When we unset this, it works correctly. Now I'm wondering why it doesn't work when UNIX95=XP64.&lt;BR /&gt;&lt;BR /&gt;You shouldn't be exporting UNIX95=MAKE_EXPR_HAVE_DIFFERENT_SUBSTR_RESULTS.&lt;BR /&gt;The POSIX standard says using substr on numbers is unpredictable.&lt;BR /&gt;&lt;BR /&gt;The only time you should use UNIX95 is with:&lt;BR /&gt;UNIX95=EXTENDED_PS ps -Hef ...&lt;BR /&gt;This only exports UNIX95 for the one command.</description>
      <pubDate>Thu, 05 Feb 2009 23:05:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155195#M684005</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-02-05T23:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155196#M684006</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Do you have PHCO_36506 ?  If not, you might try applying it (no reboot is required) and then retest.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 05 Feb 2009 23:09:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155196#M684006</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-02-05T23:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155197#M684007</link>
      <description>Uh... just noticed a typo&lt;BR /&gt;We were exporting UNIX95=XPG4&lt;BR /&gt;&lt;BR /&gt;Time for glasses...</description>
      <pubDate>Thu, 05 Feb 2009 23:27:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155197#M684007</guid>
      <dc:creator>Paul Maglinger</dc:creator>
      <dc:date>2009-02-05T23:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155198#M684008</link>
      <description>&amp;gt;JRF: Do you have PHCO_36506? &lt;BR /&gt;&lt;BR /&gt;Why would a shell patch break the correct standard behavior of expr(1), to make it work like Paul wants?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;just noticed a typo, We were exporting UNIX95=XPG4&lt;BR /&gt;&lt;BR /&gt;No, you were really exporting:  :-)&lt;BR /&gt;UNIX95=MAKE_EXPR_HAVE_DIFFERENT_SUBSTR_RESULTS&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Time for glasses&lt;BR /&gt;&lt;BR /&gt;Or cut &amp;amp; past.  :-)</description>
      <pubDate>Thu, 05 Feb 2009 23:33:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155198#M684008</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-02-05T23:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155199#M684009</link>
      <description>HI (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: Why would a shell patch break the correct standard behavior of expr(1), to make it work like Paul wants?&lt;BR /&gt; &lt;BR /&gt;A long shot, granted, but why not ask about the latest cumulative shell patch?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;</description>
      <pubDate>Thu, 05 Feb 2009 23:43:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155199#M684009</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-02-05T23:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155200#M684010</link>
      <description>&amp;gt;JRF: A long shot, granted&lt;BR /&gt;&lt;BR /&gt;I suppose that make sense if you hadn't read my reply stating that expr(1) is working as mandated by the POSIX Standard.</description>
      <pubDate>Fri, 06 Feb 2009 02:01:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155200#M684010</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-02-06T02:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155201#M684011</link>
      <description>UNIX95 will have unexpected results on a number of different commands and libraries. Unless you search through every man page, even the simplest form of defining UNIX95 will trigger unique behavior.  That's why exporting, even defining the variable in the current shell is never recommended. &lt;BR /&gt; &lt;BR /&gt;Instead, UNIX95 should be defined (appear on the right side of =) just for the process such as ps:&lt;BR /&gt; &lt;BR /&gt;UNIX95= ps -eH&lt;BR /&gt; &lt;BR /&gt;As far as I know, UNIX95 only has to be defined, null as the above example, or assigned any string to change behavior.</description>
      <pubDate>Fri, 06 Feb 2009 03:34:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155201#M684011</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2009-02-06T03:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155202#M684012</link>
      <description>&lt;!--!*#--&gt;&amp;gt;Bill: Unless you search through every man page&lt;BR /&gt;&lt;BR /&gt;Unfortunately that's not good enough.  :-(&lt;BR /&gt;Only these are documented, not expr(1).&lt;BR /&gt;for i in /usr/share/man/man1.Z/*; do&lt;BR /&gt;   zcat $i | fgrep -q UNIX95&lt;BR /&gt;   if [ $? -eq 0 ]; then echo $(basename $i); fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;awk.1 cp.1 edit.1 ex.1 find.1 patch.1 pr.1 ps.1 vedit.1 vi.1 view.1&lt;BR /&gt;11.31:&lt;BR /&gt;admin.1 alias.1 asa.1 awk.1 bg.1 cal.1 cp.1 cu.1&lt;BR /&gt;date.1 edit.1 ex.1 fc.1 fg.1 jobs.1 make.1 nl.1&lt;BR /&gt;od.1 patch.1 ps.1 pwd.1 rsh.1 sed.1 sh-posix.1&lt;BR /&gt;sort.1 unalias.1 vedit.1 vi.1 view.1 wc.1 who.1 xd.1</description>
      <pubDate>Fri, 06 Feb 2009 06:06:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155202#M684012</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-02-06T06:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155203#M684013</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: I suppose that [would] make sense if you hadn't read my reply stating that expr(1) is working as mandated by the POSIX Standard.&lt;BR /&gt;&lt;BR /&gt;Yes, for the record, I didn't see that in the ~ 4-minutes between my suggestion to fetch the cumulative sh-posix patch and your indication that "The POSIX standard says using substr on numbers is unpredictable".&lt;BR /&gt;&lt;BR /&gt;That's good to know and it suggests that one has to look at the POSIX standards to be aware of this.&lt;BR /&gt;&lt;BR /&gt;Paul's example is with a string, albeit that the string consists of digits.  Does the standard distinguish between "strings", "integers" and "strings of numbers"?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 06 Feb 2009 13:05:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155203#M684013</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-02-06T13:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155204#M684014</link>
      <description>Always a pleasure to start up a lively conversation.  Your information was quite useful and I appreciate your comments.&lt;BR /&gt;&lt;BR /&gt;Just a side note that I'm getting better information (and faster) from this forum than I'm getting from the HP software support that we're paying for.&lt;BR /&gt;&lt;BR /&gt;Thanks guys!</description>
      <pubDate>Fri, 06 Feb 2009 13:30:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155204#M684014</guid>
      <dc:creator>Paul Maglinger</dc:creator>
      <dc:date>2009-02-06T13:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: expr stripping off leading zeroes from a string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155205#M684015</link>
      <description>&amp;gt;... than I'm getting from the HP software support that we're paying for.&lt;BR /&gt;&lt;BR /&gt;Very indirectly that pays for me.  :-)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;JRF: Does the standard distinguish between "strings", "integers" and "strings of numbers"?&lt;BR /&gt;&lt;BR /&gt;The latter doesn't exist:  &lt;BR /&gt;A string argument is an argument that cannot be identified as an integer argument&lt;BR /&gt;&lt;BR /&gt;The source checks if numeric and strips leading zeros.&lt;BR /&gt;&lt;BR /&gt;The "APPLICATION USAGE" gives you a hint how to solve the problem:&lt;BR /&gt;expr substr X"$x" 2 2&lt;BR /&gt;</description>
      <pubDate>Sat, 07 Feb 2009 02:46:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/expr-stripping-off-leading-zeroes-from-a-string/m-p/5155205#M684015</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-02-07T02:46:17Z</dc:date>
    </item>
  </channel>
</rss>

