The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 09-13-2007
bluemoon1 bluemoon1 is offline
Registered User
 

Join Date: Sep 2007
Posts: 53
how to get return code in one line

I know how to get the returning code of a function but wonder if I can combine the follwoing two lines into one:
e.g.:
#!/bin/shell
...
#line 1
MyFunction arg1 arg 2
#line 2
rec=$? #this will be evaluated later
....

like in c/c++, we'd write one line:
rec=MyFunction(arg1, arg 2)

Because I have many of those funciton calls in one script where all return codes need to be collected & evaluated later. It'd look nicer with one less line here.

Thanks in advance.

Last edited by bluemoon1; 09-13-2007 at 02:45 PM..
Reply With Quote
Remove advertisements
!!
Forum Sponsor