<?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 continue for a loop ? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855994#M98192</link>
    <description>&lt;!--!*#--&gt;hello,&lt;BR /&gt;&lt;BR /&gt;i try to make an exit function like that:&lt;BR /&gt;&lt;BR /&gt;fct_exit () {&lt;BR /&gt;   RVAL="${?}"&lt;BR /&gt;   test "${RVAL}" != "0" &amp;amp;&amp;amp; {&lt;BR /&gt; echo "Erreur ${1}"&lt;BR /&gt; continue&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;but that don't works in a loop i think because the continue is interpreted by the function itself:&lt;BR /&gt;&lt;BR /&gt;for i in "unavailable available"&lt;BR /&gt;do&lt;BR /&gt;cat $i&lt;BR /&gt;fct_exit "erreur number 1"&lt;BR /&gt;echo $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;the result give me the $1 value and unavailable and the available echo ;(&lt;BR /&gt;if i replace "continue" by an "exit", the script stops, but it's not what i want.&lt;BR /&gt;&lt;BR /&gt;someone can help the newbie i am please?&lt;BR /&gt;Regards,&lt;BR /&gt;Cedrick Gaillard</description>
    <pubDate>Mon, 04 Sep 2006 04:59:32 GMT</pubDate>
    <dc:creator>totoperdu</dc:creator>
    <dc:date>2006-09-04T04:59:32Z</dc:date>
    <item>
      <title>continue for a loop ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855994#M98192</link>
      <description>&lt;!--!*#--&gt;hello,&lt;BR /&gt;&lt;BR /&gt;i try to make an exit function like that:&lt;BR /&gt;&lt;BR /&gt;fct_exit () {&lt;BR /&gt;   RVAL="${?}"&lt;BR /&gt;   test "${RVAL}" != "0" &amp;amp;&amp;amp; {&lt;BR /&gt; echo "Erreur ${1}"&lt;BR /&gt; continue&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;but that don't works in a loop i think because the continue is interpreted by the function itself:&lt;BR /&gt;&lt;BR /&gt;for i in "unavailable available"&lt;BR /&gt;do&lt;BR /&gt;cat $i&lt;BR /&gt;fct_exit "erreur number 1"&lt;BR /&gt;echo $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;the result give me the $1 value and unavailable and the available echo ;(&lt;BR /&gt;if i replace "continue" by an "exit", the script stops, but it's not what i want.&lt;BR /&gt;&lt;BR /&gt;someone can help the newbie i am please?&lt;BR /&gt;Regards,&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Mon, 04 Sep 2006 04:59:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855994#M98192</guid>
      <dc:creator>totoperdu</dc:creator>
      <dc:date>2006-09-04T04:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: continue for a loop ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855995#M98193</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;quote around "unavailable available"&lt;BR /&gt;make it a single argument, hence your loop is executed once.&lt;BR /&gt;&lt;BR /&gt;if you remove quote, you'll get :&lt;BR /&gt;&lt;BR /&gt;cat: Cannot open unavailable: No such file or directory&lt;BR /&gt;Erreur erreur number 1&lt;BR /&gt;unavailable&lt;BR /&gt;Mon Sep  4 13:50:40 METDST 2006&lt;BR /&gt;available&lt;BR /&gt;&lt;BR /&gt;I am not sure continue will work inside a function contained is a loop.&lt;BR /&gt;((because, function environment overide loop.&lt;BR /&gt;in other word loop is not seen from inside the function. ))&lt;BR /&gt;&lt;BR /&gt;use return inside function and continuie outside :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fct_exit () {&lt;BR /&gt;   RVAL="${?}"&lt;BR /&gt;   x=1&lt;BR /&gt;   test "${RVAL}" != "0" &amp;amp;&amp;amp; {&lt;BR /&gt;   echo "Erreur ${1}"&lt;BR /&gt;    x=0&lt;BR /&gt;   }&lt;BR /&gt;   return $x&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for i in unavailable available&lt;BR /&gt;do&lt;BR /&gt;cat $i&lt;BR /&gt;if fct_exit "erreur number 1"&lt;BR /&gt;then continue&lt;BR /&gt;fi&lt;BR /&gt;echo echo $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Jean-Yves Picard</description>
      <pubDate>Mon, 04 Sep 2006 07:10:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855995#M98193</guid>
      <dc:creator>Jean-Yves Picard</dc:creator>
      <dc:date>2006-09-04T07:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: continue for a loop ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855996#M98194</link>
      <description>&lt;!--!*#--&gt;thanks for your answer.&lt;BR /&gt;&lt;BR /&gt;the goal is to reduce the scripts, with your way, tests are added and it's not what i want.&lt;BR /&gt;&lt;BR /&gt;i also have tried :&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;for i in toto tata tutu&lt;BR /&gt;do&lt;BR /&gt;fct_exit="$(if [ ! -r "${i}" ] ; then continue ; fi)"&lt;BR /&gt;&lt;BR /&gt;echo ${i}&lt;BR /&gt;${fct_exit}&lt;BR /&gt;echo "-"&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;but that do not works more ;-(&lt;BR /&gt;&lt;BR /&gt;thanks for your help&lt;BR /&gt;Cheers,&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Mon, 04 Sep 2006 07:43:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855996#M98194</guid>
      <dc:creator>totoperdu</dc:creator>
      <dc:date>2006-09-04T07:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: continue for a loop ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855997#M98195</link>
      <description>&lt;!--!*#--&gt;Hi Cedrick:&lt;BR /&gt;&lt;BR /&gt;I suggest this, using an inline approach:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;for i in unavailable available&lt;BR /&gt;do&lt;BR /&gt;cat $i 2&amp;gt; /dev/null&lt;BR /&gt;[ $? != 0 ] &amp;amp;&amp;amp; { echo "Erreur ${i}"; continue; }&lt;BR /&gt;echo $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;...I have added the redirection of STDERR for 'cat' to 'dev'null'.  This eliminates 'cat' reporting the non-existent file and leaves only your "Erreur ${i}".&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 04 Sep 2006 07:54:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855997#M98195</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-09-04T07:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: continue for a loop ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855998#M98196</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;you second try can't work, the instruction&lt;BR /&gt;&lt;BR /&gt;fct_exit="$(if [ ! -r "${i}" ] ; then continue ; fi)"&lt;BR /&gt;&lt;BR /&gt;fork a new shell, continue in this shell can't be related to for loop in previous shell.&lt;BR /&gt;&lt;BR /&gt;James's solution is a bit better.&lt;BR /&gt;&lt;BR /&gt;however, in real world, what you want to put in the function is more likely the real code instead of echo "Erreur ${1}".&lt;BR /&gt;this is what you should use a function for.&lt;BR /&gt;&lt;BR /&gt;code overhead for James's solution or mine is light.&lt;BR /&gt;besides hiding a continue inside a function will greatly hinder debugging ...&lt;BR /&gt;&lt;BR /&gt;Jean-Yves Picard</description>
      <pubDate>Mon, 04 Sep 2006 08:04:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855998#M98196</guid>
      <dc:creator>Jean-Yves Picard</dc:creator>
      <dc:date>2006-09-04T08:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: continue for a loop ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855999#M98197</link>
      <description>Hi (again) Cedrick:&lt;BR /&gt;&lt;BR /&gt;This will come close to the format you were originally trying to achieve.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;fct_exit () {&lt;BR /&gt;   RVAL="${?}"&lt;BR /&gt;   test "${RVAL}" != "0" &amp;amp;&amp;amp; {&lt;BR /&gt;      echo "Erreur ${1}"&lt;BR /&gt;      return 1&lt;BR /&gt;      }&lt;BR /&gt;   return 0&lt;BR /&gt;}&lt;BR /&gt;for i in unavailable available&lt;BR /&gt;do&lt;BR /&gt;   cat $i&lt;BR /&gt;   fct_exit "erreur number 1" || continue&lt;BR /&gt;   echo $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 04 Sep 2006 09:16:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3855999#M98197</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-09-04T09:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: continue for a loop ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3856000#M98198</link>
      <description>The "continue" statement applies only to loops and not to "test" cases. Could you explain what exactly you are trying to do inside your function "fct_exit".&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/B2355-90046/ch21s05.html" target="_blank"&gt;http://docs.hp.com/en/B2355-90046/ch21s05.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;thanks!</description>
      <pubDate>Mon, 04 Sep 2006 13:39:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3856000#M98198</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-09-04T13:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: continue for a loop ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3856001#M98199</link>
      <description>&lt;!--!*#--&gt;Give the script below a try...&lt;BR /&gt;&lt;BR /&gt;=============================================&lt;BR /&gt;#!/bin/sh -x&lt;BR /&gt;&lt;BR /&gt;fct_exit () {&lt;BR /&gt;   RVAL="${?}"&lt;BR /&gt;   test "${RVAL}" != "0" &amp;amp;&amp;amp; {&lt;BR /&gt;   echo "Erreur ${1}"&lt;BR /&gt;   }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for i in unavailable available&lt;BR /&gt;do&lt;BR /&gt;    cat $i 2&amp;gt;/dev/null || fct_exit&lt;BR /&gt;done&lt;BR /&gt;=============================================&lt;BR /&gt;&lt;BR /&gt;cheers!</description>
      <pubDate>Mon, 04 Sep 2006 16:37:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3856001#M98199</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-09-04T16:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: continue for a loop ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3856002#M98200</link>
      <description>Thanks Jean-Yves Picard but i have already tried to insert into a var with no success.&lt;BR /&gt;maybe i made a mistake.&lt;BR /&gt;&lt;BR /&gt;Thanks ...JRF... i will try the 'return 1' asap ;)&lt;BR /&gt;&lt;BR /&gt;Thanks Sandman but i don't understand your link : &lt;A href="http://docs.hp.com/en/B2355-90046/ch21s05.html" target="_blank"&gt;http://docs.hp.com/en/B2355-90046/ch21s05.html&lt;/A&gt;&lt;BR /&gt;it says: continue skips any lines following it in a for, while, until, or select loop&lt;BR /&gt;&lt;BR /&gt;in my case, my function is not in a for, while, until, or select loop.&lt;BR /&gt;&lt;BR /&gt;it's why i'm confused.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Tue, 05 Sep 2006 05:11:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/continue-for-a-loop/m-p/3856002#M98200</guid>
      <dc:creator>totoperdu</dc:creator>
      <dc:date>2006-09-05T05:11:50Z</dc:date>
    </item>
  </channel>
</rss>

