<?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: Command substitution strange behavior? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521261#M651502</link>
    <description>I said HP-UX because i se the problem in both posix-shell and ksh.&lt;BR /&gt;&lt;BR /&gt;I know all about shells.&lt;BR /&gt;I have worked vith HP-UX and other unixes for more than 15 years and been teathing HP-UX at HP.&lt;BR /&gt;&lt;BR /&gt;That is why i do not understand the difference.&lt;BR /&gt;&lt;BR /&gt;Regards Jesper</description>
    <pubDate>Tue, 27 Oct 2009 06:03:40 GMT</pubDate>
    <dc:creator>Jesper Sivertsen</dc:creator>
    <dc:date>2009-10-27T06:03:40Z</dc:date>
    <item>
      <title>Command substitution strange behavior?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521255#M651496</link>
      <description>Hi there &lt;BR /&gt;I have seen a strange behavior i HP-UX that sombody have to explain to mee??&lt;BR /&gt;&lt;BR /&gt;If you try this scipt:&lt;BR /&gt;---------------------------------&lt;BR /&gt;RES=$(cat &amp;lt;&lt;END&gt;&lt;/END&gt;single 'qoute'&lt;BR /&gt;double "qoute"&lt;BR /&gt;single \'qoute\'&lt;BR /&gt;END&lt;BR /&gt;)&lt;BR /&gt;echo $RES&lt;BR /&gt;RES=`cat &amp;lt;&lt;END&gt;&lt;/END&gt;single 'qoute'&lt;BR /&gt;double "qoute"&lt;BR /&gt;single \'qoute\'&lt;BR /&gt;END&lt;BR /&gt;`&lt;BR /&gt;echo $RES&lt;BR /&gt;---------------------------------&lt;BR /&gt;&lt;BR /&gt;In HP-UX the result is:&lt;BR /&gt;single "qoute" double "qoute" single \'qoute\'&lt;BR /&gt;single 'qoute' double "qoute" single \'qoute\'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But in linux bash it is ( as exspected) :&lt;BR /&gt;single 'qoute' double "qoute" single \'qoute\'&lt;BR /&gt;single 'qoute' double "qoute" single \'qoute\'&lt;BR /&gt;&lt;BR /&gt;Why is there a diffrense in HP-UX between $() and `` ?&lt;BR /&gt;&lt;BR /&gt;Regards Jesper</description>
      <pubDate>Mon, 26 Oct 2009 15:49:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521255#M651496</guid>
      <dc:creator>Jesper Sivertsen</dc:creator>
      <dc:date>2009-10-26T15:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Command substitution strange behavior?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521256#M651497</link>
      <description>Hi Jesper:&lt;BR /&gt;&lt;BR /&gt;First, the HP-UX Posix shell ('/usr/bin/sh' or '/sbin/sh') does differ from the 'bash' shell.&lt;BR /&gt;&lt;BR /&gt;I can't offer a reason for the difference you see, however.&lt;BR /&gt;&lt;BR /&gt;It is interesting, though, that if you do:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;cat &amp;lt;&lt;END&gt;&lt;/END&gt;single 'qoute' double "qoute" single \'qoute\'&lt;BR /&gt;END&lt;BR /&gt;cat &amp;lt;&lt;END&gt;&lt;/END&gt;single 'qoute' double "qoute" single \'qoute\'&lt;BR /&gt;END&lt;BR /&gt;&lt;BR /&gt;...you get the expected:&lt;BR /&gt;&lt;BR /&gt;single 'qoute' double "qoute" single \'qoute\'&lt;BR /&gt;single 'qoute' double "qoute" single \'qoute\'&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;I'm not sure why you are resorting to collecting a here-doc in a variable and then echoing that variable.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 26 Oct 2009 16:08:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521256#M651497</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-10-26T16:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Command substitution strange behavior?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521257#M651498</link>
      <description>For what it may be worth,in ksh on AIX, the result is identical to the HP-UX output the OP posted.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Oct 2009 16:41:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521257#M651498</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-10-26T16:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Command substitution strange behavior?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521258#M651499</link>
      <description>This is just an example to show the "problem".&lt;BR /&gt;I use the construction to run sqlplus from oracle and get the result in a variable.&lt;BR /&gt;&lt;BR /&gt;Jesper</description>
      <pubDate>Mon, 26 Oct 2009 16:53:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521258#M651499</guid>
      <dc:creator>Jesper Sivertsen</dc:creator>
      <dc:date>2009-10-26T16:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Command substitution strange behavior?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521259#M651500</link>
      <description>Just to clarify: HP-UX doesn't know anything about quotes and strings and echo. HP-UX is an OS just like Linux. What you are describing is specific to shell programs, and just like Linux and AIX, HP-UX has several shells. As mentioned, the typical shell for HP-UX is the POSIX shell: /usr/bin/sh and not to be confused with the Bourne shell: /usr/old/bin/sh. But you may have been given the Korn shell (aka, ksh-88) for your login on HP-UX, or maybe an optional shell called Bash.&lt;BR /&gt; &lt;BR /&gt;The $() construct is always preferred for modern shells as it can provide unambiguous nesting and is infinitely easier to document properly. The reason is that ' and ` are very, very often typed incorrectly. Read the man page for sh-posix (HP-UX), ksh (any OS) and Bash (any OS) to see the deprecation (obsolete) of grave accents for command substitution.&lt;BR /&gt; &lt;BR /&gt;Bottom line, there are differences between shells. I don't have a clear explanation for the changing of single quotes into double quotes. But as you might imagine, characters that special meaning to the shell will always need extra handling.</description>
      <pubDate>Mon, 26 Oct 2009 23:55:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521259#M651500</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2009-10-26T23:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Command substitution strange behavior?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521260#M651501</link>
      <description>Jesper,&lt;BR /&gt;&lt;BR /&gt;Check this out , similar bash WT... page:&lt;BR /&gt; you will find more interesting stuff,&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://almirkaric.com/tag/awk/" target="_blank"&gt;http://almirkaric.com/tag/awk/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Hth,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Oct 2009 00:08:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521260#M651501</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2009-10-27T00:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Command substitution strange behavior?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521261#M651502</link>
      <description>I said HP-UX because i se the problem in both posix-shell and ksh.&lt;BR /&gt;&lt;BR /&gt;I know all about shells.&lt;BR /&gt;I have worked vith HP-UX and other unixes for more than 15 years and been teathing HP-UX at HP.&lt;BR /&gt;&lt;BR /&gt;That is why i do not understand the difference.&lt;BR /&gt;&lt;BR /&gt;Regards Jesper</description>
      <pubDate>Tue, 27 Oct 2009 06:03:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521261#M651502</guid>
      <dc:creator>Jesper Sivertsen</dc:creator>
      <dc:date>2009-10-27T06:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Command substitution strange behavior?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521262#M651503</link>
      <description>&amp;gt;I have seen a strange behavior I HP-UX that somebody have to explain to me?&lt;BR /&gt;&lt;BR /&gt;It looks like a bug with new-fangled $() and here documents.  Please report it to the Response Center.&lt;BR /&gt;&lt;BR /&gt;RES=$(cat &amp;lt;&lt;END&gt;&lt;/END&gt;&lt;BR /&gt;It fails even with: &amp;lt;&amp;lt;\END&lt;BR /&gt;If you do this, you see the here documented is messed up when it parses the $():&lt;BR /&gt;RES=$(cat &amp;lt;&amp;lt;\END &amp;gt; /dev/tty&lt;BR /&gt;single 'qoute'&lt;BR /&gt;double "qoute"&lt;BR /&gt;single \'qoute\'&lt;BR /&gt;END&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;JRF: I can't offer a reason for the difference you see&lt;BR /&gt;&lt;BR /&gt;It's broken.  :-(&lt;BR /&gt;&lt;BR /&gt;&amp;gt;It is interesting, though, that if you do:&lt;BR /&gt;&lt;BR /&gt;That doesn't mix the gas with a match.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Bill: characters that special meaning to the shell will always need extra handling.&lt;BR /&gt;&lt;BR /&gt;And it failed.</description>
      <pubDate>Tue, 27 Oct 2009 09:46:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521262#M651503</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-10-27T09:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Command substitution strange behavior?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521263#M651504</link>
      <description>It's interesting that both sh and ksh are ksh88 type shells, whereas dtksh which is a ksh93 type shell works as expected...&lt;BR /&gt;&lt;BR /&gt;# more ./de.sh&lt;BR /&gt;#!/usr/dt/bin/dtksh&lt;BR /&gt;RES=$(cat &amp;lt;&lt;END&gt;&lt;/END&gt;single 'qoute'&lt;BR /&gt;double "qoute"&lt;BR /&gt;single \'qoute\'&lt;BR /&gt;END&lt;BR /&gt;)&lt;BR /&gt;echo $RES&lt;BR /&gt;RES=`cat &amp;lt;&lt;END&gt;&lt;/END&gt;single 'qoute'&lt;BR /&gt;double "qoute"&lt;BR /&gt;single \'qoute\'&lt;BR /&gt;END&lt;BR /&gt;`&lt;BR /&gt;echo $RES&lt;BR /&gt;&lt;BR /&gt;# ./de.sh&lt;BR /&gt;single 'qoute' double "qoute" single \'qoute\'&lt;BR /&gt;single 'qoute' double "qoute" single \'qoute\'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Wonder if this is some obscure feature - the POSIX/IEEE standards are almost impossible for joe-admins like me to make sense of, but I wonder if there is something in there that might explain this behaviour...&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Tue, 27 Oct 2009 13:11:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-substitution-strange-behavior/m-p/4521263#M651504</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2009-10-27T13:11:57Z</dc:date>
    </item>
  </channel>
</rss>

