<?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: Printf bug? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886065#M935486</link>
    <description>Not really. The shell is seeing a leading zero and is trying to intepret the value as an octal value. 08 and 09 are invalid.&lt;BR /&gt;&lt;BR /&gt;Change&lt;BR /&gt;HR=08&lt;BR /&gt;to typeset -i HR=08&lt;BR /&gt;and all will be well.&lt;BR /&gt;</description>
    <pubDate>Mon, 20 Jan 2003 22:44:25 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2003-01-20T22:44:25Z</dc:date>
    <item>
      <title>Printf bug?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886064#M935485</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I am having a problem with using printf in a script.&lt;BR /&gt;&lt;BR /&gt;HR=08&lt;BR /&gt;printf "Hour: %02d\n" $HR&lt;BR /&gt;&lt;BR /&gt;printf:  Error converting 08&lt;BR /&gt;&lt;BR /&gt;It works for 00 01 02 03 04 05 06 07 10 11 12. Is this a bug that I need to report to HP?&lt;BR /&gt;&lt;BR /&gt;Thanks, Kris</description>
      <pubDate>Mon, 20 Jan 2003 22:42:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886064#M935485</guid>
      <dc:creator>Kris Spander</dc:creator>
      <dc:date>2003-01-20T22:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Printf bug?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886065#M935486</link>
      <description>Not really. The shell is seeing a leading zero and is trying to intepret the value as an octal value. 08 and 09 are invalid.&lt;BR /&gt;&lt;BR /&gt;Change&lt;BR /&gt;HR=08&lt;BR /&gt;to typeset -i HR=08&lt;BR /&gt;and all will be well.&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Jan 2003 22:44:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886065#M935486</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-01-20T22:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Printf bug?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886066#M935487</link>
      <description>printf() appears to be converting your input&lt;BR /&gt;string "08" to an integer using the usual C&lt;BR /&gt;language conventions; that is, a leading "0x"&lt;BR /&gt;means the number is in hexadecimal, and a&lt;BR /&gt;leading "0" means the number is in octal.&lt;BR /&gt;"8" is not a valid digit in an octal number.&lt;BR /&gt;&lt;BR /&gt;You'll need to either strip off the leading 0&lt;BR /&gt;or use "typeset -i" to make ksh treat HR&lt;BR /&gt;as an integer.&lt;BR /&gt;&lt;BR /&gt;typeset -i HR&lt;BR /&gt;HR=08&lt;BR /&gt;printf "Hour: %02d\n" $HR&lt;BR /&gt;&lt;BR /&gt;Hour: 08&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Jan 2003 22:53:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886066#M935487</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2003-01-20T22:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Printf bug?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886067#M935488</link>
      <description>I got bitten by this in January when the month changed from 12 to 01. &lt;BR /&gt;&lt;BR /&gt;There is a difference between /bin/sh and /usr/bin/ksh.  I had to change the first line of my script from&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;to&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;I was doing &lt;BR /&gt;now=`date +%m%d`&lt;BR /&gt;time=$((now - 1))&lt;BR /&gt; and /bin/sh gives the wrong results.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Jan 2003 10:30:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886067#M935488</guid>
      <dc:creator>Martin Robinson</dc:creator>
      <dc:date>2003-01-21T10:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Printf bug?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886068#M935489</link>
      <description>With recent patches the POSIX shell (/sbin/sh and /usr/sbin/sh) was changed to comply with latest POSIX standards. So, what you are seeing is designed behaviour.&lt;BR /&gt;&lt;BR /&gt;For details see e.g. patch text of PHCO_25597 (JAGad93413 and its special installation instructions).&lt;BR /&gt;&lt;BR /&gt;Best regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Tue, 21 Jan 2003 11:40:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-bug/m-p/2886068#M935489</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2003-01-21T11:40:46Z</dc:date>
    </item>
  </channel>
</rss>

