home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 41,776 of 42,547   
   Anton Shepelev to All   
   Re: A failed output redirection does not   
   11 Nov 19 19:31:19   
   
   From: anton.txt@g{oogle}mail.com   
      
   Herbert Kleebauer:   
      
   > I  did not misunderstand you, I corrected the line   
   > in my answer (est.txt  instead  of  test.txt,  but   
   > that doesn't matter):   
      
   I beg your pardon then.   
      
   > I gave you the explanation and the solution.   
      
   Your  solutiuon works indeed, but I don't understand   
   the explanation:   
      
   > type resets the errorlevel to 0 on success, so set it   
   > to 1 before you execute type.   
   >   
   > @echo off   
   > call :set_err 1   
   > echo test>a   
   >   
   > type a > C:\NOSUCHNDIR\est.txt   
   > IF ERRORLEVEL 1 goto ERROR   
   > echo All is well.   
   > goto END   
   > :ERROR   
   > echo Error detected.   
   > :END   
   >   
   > goto :eof   
   >   
   > :set_err   
   > exit /b %1   
      
   The line   
      
      type a > C:\NOSUCHNDIR\est.txt   
      
   contains two actions: an invocation  of  `type'  and   
   the  redirection of its output to a file.  If `type'   
   resets ERRORLEVEL on success, why does the  previous   
   value of ERRORLEVEL matter?  If a failed redirection   
   sets ERRORLEVEL, why does the result of `type'  mat-   
   ter?   Perhaps I misunderstand the sequence in which   
   the shell executes that line...   
      
   --   
   ()  ascii ribbon campaign - against html e-mail   
   /\  http://preview.tinyurl.com/qcy6mjc [archived]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca