The UNIX and Linux Forums  

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


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Creating functions in shell script gjithin Shell Programming and Scripting 1 05-10-2008 12:15 AM
How to call C functions in shell scripts? agarwal Shell Programming and Scripting 5 04-08-2008 09:03 PM
Calling shell functions from another shell script jisha Shell Programming and Scripting 6 04-05-2008 01:29 PM
Functions in C-Shell Raynon Shell Programming and Scripting 1 07-13-2007 06:17 AM
functions in c shell?? ballazrus Shell Programming and Scripting 1 02-16-2006 02:14 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-09-2005
Registered User
 

Join Date: Dec 2005
Posts: 3
Shell script functions

Simple shell script :

date
test_fn()
{
echo "function within test shell script "
}


on the shell prompt I run
> . test

Then I invoke the function on the command line as below :
test_fn()

It echos the line
function within test shell script
and works as expected.

Question (1) how do I find out what are all the shell functions known to the current shell ? I tried set but that does not show my function . I tried which test_fn but that too says it does not know about test_fn
(2) how to I make the current shell get rid of the function. I tried unset test_fn - but that does not do it and returns an exit status of 1.

Thank you
Ram
Reply With Quote
Forum Sponsor
  #2  
Old 12-09-2005
moxxx68's Avatar
Registered User
 

Join Date: Mar 2004
Posts: 301
try man bash! (or ksh,csh-tcsh whichever)
it will give you the right
variables to find status and such

for example
if you want to know the return status of the last command
type:
$ $?

to find out what parameter options were set i believe its
$- (ex, set -C,) would return a noclobber option
and so on..

man bash is usually where you will get answers to questions like
these.. set -F etc, etc.

hope that helps
moxxx68
__________________
moxxx68
http://www.estarinformado.com.ar/apicmaxmiel/bee-diez.gif
Reply With Quote
  #3  
Old 12-12-2005
Registered User
 

Join Date: Dec 2005
Posts: 3
moxxx68 - Thanks for your reply, but, that didn't help much.
I want to know what are the exact command and switches in order to display the names of all the functions currently known to the shell.
And how to remove the definition of the function from the shell.

Thanks,
Ram
Reply With Quote
  #4  
Old 12-12-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
In ksh, use "typeset +f" and "unset -f".
Reply With Quote
  #5  
Old 12-12-2005
moxxx68's Avatar
Registered User
 

Join Date: Mar 2004
Posts: 301
can't be that difficult to look it in the man pages can it?
moxxx68
your're welcome!
__________________
moxxx68
http://www.estarinformado.com.ar/apicmaxmiel/bee-diez.gif
Reply With Quote
  #6  
Old 12-13-2005
Registered User
 

Join Date: Dec 2005
Posts: 3
Perderabo - Super ! Those worked. Thanks much.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0