<?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 bash and sh difference in break this while do loop in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729231#M100984</link>
    <description>This is an extract from /opt/VRTS/bin/vxrootmir&lt;BR /&gt;&lt;BR /&gt;        tfound=no&lt;BR /&gt;        tmpdg=&lt;BR /&gt;        mdm=&lt;BR /&gt;        mda=&lt;BR /&gt;&lt;BR /&gt;        vxdisk -q list | \&lt;BR /&gt;        while read da type dm grp state rest&lt;BR /&gt;        do&lt;BR /&gt;                if [ "$dm" = "$1" ]; then&lt;BR /&gt;                        tmpdg=$grp&lt;BR /&gt;                        mdm=$1&lt;BR /&gt;                        tfound=yes&lt;BR /&gt;                        break&lt;BR /&gt;                elif [ "$da" = "$1" ]; then&lt;BR /&gt;                        if [ "$dm" != "-" ]; then&lt;BR /&gt;                                tmpdg=$grp&lt;BR /&gt;                                mdm=$dm&lt;BR /&gt;                        fi&lt;BR /&gt;                        tfound=yes&lt;BR /&gt;                        break&lt;BR /&gt;                fi&lt;BR /&gt;        done&lt;BR /&gt;&lt;BR /&gt;        if [ "$tfound" = "no" ]; then&lt;BR /&gt;                abort "Disk $1 not found in configuration" vxvmshm:0&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here's what I would like to explain: under bash (3.00.14) the tfound variable is set to "no" again after it is set to "yes" and breaks after the first if. Because of that the disk not found message is displayed and the script exits unsuccessfully.&lt;BR /&gt;&lt;BR /&gt;This behavior does not happen under sh. It looks so simple but... why?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;james</description>
    <pubDate>Fri, 10 Feb 2006 13:47:37 GMT</pubDate>
    <dc:creator>jamesps</dc:creator>
    <dc:date>2006-02-10T13:47:37Z</dc:date>
    <item>
      <title>bash and sh difference in break this while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729231#M100984</link>
      <description>This is an extract from /opt/VRTS/bin/vxrootmir&lt;BR /&gt;&lt;BR /&gt;        tfound=no&lt;BR /&gt;        tmpdg=&lt;BR /&gt;        mdm=&lt;BR /&gt;        mda=&lt;BR /&gt;&lt;BR /&gt;        vxdisk -q list | \&lt;BR /&gt;        while read da type dm grp state rest&lt;BR /&gt;        do&lt;BR /&gt;                if [ "$dm" = "$1" ]; then&lt;BR /&gt;                        tmpdg=$grp&lt;BR /&gt;                        mdm=$1&lt;BR /&gt;                        tfound=yes&lt;BR /&gt;                        break&lt;BR /&gt;                elif [ "$da" = "$1" ]; then&lt;BR /&gt;                        if [ "$dm" != "-" ]; then&lt;BR /&gt;                                tmpdg=$grp&lt;BR /&gt;                                mdm=$dm&lt;BR /&gt;                        fi&lt;BR /&gt;                        tfound=yes&lt;BR /&gt;                        break&lt;BR /&gt;                fi&lt;BR /&gt;        done&lt;BR /&gt;&lt;BR /&gt;        if [ "$tfound" = "no" ]; then&lt;BR /&gt;                abort "Disk $1 not found in configuration" vxvmshm:0&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here's what I would like to explain: under bash (3.00.14) the tfound variable is set to "no" again after it is set to "yes" and breaks after the first if. Because of that the disk not found message is displayed and the script exits unsuccessfully.&lt;BR /&gt;&lt;BR /&gt;This behavior does not happen under sh. It looks so simple but... why?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;james</description>
      <pubDate>Fri, 10 Feb 2006 13:47:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729231#M100984</guid>
      <dc:creator>jamesps</dc:creator>
      <dc:date>2006-02-10T13:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: bash and sh difference in break this while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729232#M100985</link>
      <description>I am using B.11.11, latest security patches.</description>
      <pubDate>Fri, 10 Feb 2006 13:52:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729232#M100985</guid>
      <dc:creator>jamesps</dc:creator>
      <dc:date>2006-02-10T13:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: bash and sh difference in break this while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729233#M100986</link>
      <description>Hi James:&lt;BR /&gt;&lt;BR /&gt;I'd use 'set -x' and perhaps add 'set -v' and trace the execution and variable setting.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 10 Feb 2006 14:00:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729233#M100986</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-10T14:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: bash and sh difference in break this while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729234#M100987</link>
      <description>I suspect that your read is the problem.&lt;BR /&gt;&lt;BR /&gt;Try this very simple test:&lt;BR /&gt;&lt;BR /&gt;echo "One Two Three" | read A B C&lt;BR /&gt;echo "A = \"${A}\""&lt;BR /&gt;echo "B = \"${B}\""&lt;BR /&gt;echo "C = \"${C}\""&lt;BR /&gt;&lt;BR /&gt;I think you will find different results in the POSIX shell and bash -- at least some implementations of bash. It's one of the reasons I'm not a huge fan of bash. My shell of choice under Linix is zsh.&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Feb 2006 15:00:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729234#M100987</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-02-10T15:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: bash and sh difference in break this while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729235#M100988</link>
      <description>Perhaps it should be == instead of = in &lt;BR /&gt;&lt;BR /&gt;if [ "$tfound" = "no" ]; then&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Feb 2006 15:10:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-and-sh-difference-in-break-this-while-do-loop/m-p/3729235#M100988</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2006-02-10T15:10:43Z</dc:date>
    </item>
  </channel>
</rss>

