On Wed, Jul 21, 2004 at 08:00:10PM +0200, Ivan IS. Sijakovski wrote:
> I'm using the lftp 3.0.6 on Solaris 8 for some automated ftp tasks.
> and I noticed that if I execute some command on a local machine (with !)
> which returns something different then 0, lftp always returns 0, i.e.
>
> $lftp -c '
> !<some bad cmd> || exit 1
> exit 2'
>
> $echo $? # returns 2, not 1
>
> or worst
>
> $lftp -c '!exit 1 || exit 1'
> $echo $? # returns 0, not 1
>
> is it possible this to be fixed?
First, ! takes whole line and executes it with external shell. So you
should write:
!<bad-cmd>
|| exit 1
or
shell "<bad-cmd>" || exit 1
Second, apply this patch to make ! and shell return exit code.
--
Alexander.
Index: SysCmdJob.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/SysCmdJob.h,v
retrieving revision 1.2
diff -u -p -r1.2 SysCmdJob.h
--- SysCmdJob.h 21 Jan 2002 16:25:16 -0000 1.2
+++ SysCmdJob.h 22 Jul 2004 08:24:45 -0000
@@ -35,6 +35,7 @@ public:
int Do();
int Done() { return(w && w->GetState()!=w->RUNNING); }
int AcceptSig(int);
+ int ExitCode() { return w?w->GetInfo()>>8:1; }
};
#endif//SYSCMDJOB_H