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
How to trace a user salhoub HP-UX 4 4 Weeks Ago 03:05 AM
how to trace the logs vivek_damodaran HP-UX 3 05-13-2008 09:09 AM
Trace DHCP - Help! nuGuy UNIX for Dummies Questions & Answers 0 04-27-2008 10:00 AM
trace route ip ppass IP Networking 2 01-11-2005 07:50 AM
Trace connections jraitsev UNIX for Advanced & Expert Users 8 03-14-2002 02:00 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-04-2007
Registered User
 

Join Date: Aug 2007
Location: Binfield, Berkshire. UK
Posts: 91
Function Trace

Does anyone know if there is a util out there to run through a shell script and be able to trace the function call tree. I have inherited some code and the original author was ****mad**** keen on functions - even ones called only once!
If anyone knows of anything I would appreciate it - web trawling has not revealed anything yet.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-04-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
You could not do this 100% because a function can be called by name from a variable.

A good clue, however, is that a function has to be defined before it can be called, so if you look through the file in order it should be basically in bottom up order.
Reply With Quote
  #3 (permalink)  
Old 10-04-2007
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 496
Hi.

You may be able to build something on your own -- see below, among the 300K hits found by Google "bash trap trace" ... cheers, drl
Quote:
# Bash includes the caller builtin, which displays the context of any active subroutine call (a shell function or a script executed with the . or source builtins). This supports the bash debugger.
# The trap builtin (see section 4.1 Bourne Shell Builtins) allows a DEBUG pseudo-signal specification, similar to EXIT. Commands specified with a DEBUG trap are executed before every simple command, for command, case command, select command, every arithmetic for command, and before the first command executes in a shell function. The DEBUG trap is not inherited by shell functions unless the function has been given the trace attribute or the functrace option has been enabled using the shopt builtin. The extdebug shell option has additional effects on the DEBUG trap.

-- excerpt from bash differences
Reply With Quote
  #4 (permalink)  
Old 10-05-2007
Registered User
 

Join Date: Aug 2007
Location: Binfield, Berkshire. UK
Posts: 91
Ta

Thanks for the pointers

cheers all
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:27 PM.


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

Content Relevant URLs by vBSEO 3.2.0