- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Display code of a shell function?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2004 10:55 PM
09-27-2004 10:55 PM
I define a function in my shell (/usr/bin/sh):
x()
{
exit;
}
Is there a way for me to look and see how x was defined? If I use:
% whence x
I get:
x
But I don't see what's inside function x. Does anyone know of a way to display what's inside x?
Hope someone has a good idea about this. I couldn't find anything documented (maybe I didn't look in the right places?).
Thanks, Christian
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2004 11:10 PM
09-27-2004 11:10 PM
Re: Display code of a shell function?
Example:
alias test='ls -l | grep "test"'
whence test
it will say that it is an alias to ls -l | grep "test"
There is a default alias to whence -v there as
alias type='whence -v'
so try as type test too
To get function information then,
alias fun='fun() { uname -a;hostname; }; fun'
It will give what did you expect that using,
whence -v fun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2004 11:14 PM
09-27-2004 11:14 PM
Re: Display code of a shell function?
whence [-pv] name ...
For each name, indicate how it would be interpreted if
used as a command name. The -v option produces a more
verbose report. The -p option does a path search for
name even if name is an alias, a function, or a
reserved word.
http://www.robelle.com/library/smugbook/whence.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2004 11:23 PM
09-27-2004 11:23 PM
Re: Display code of a shell function?
typeset +f
$ fun()
> {
> hostname
> uname -a
> }
$ fun
<...>
$ typeset +f
will give all function code there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2004 11:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2004 11:28 PM
09-27-2004 11:28 PM
Re: Display code of a shell function?
Thanks for your hints.
1. I am using /usr/bin/sh, not korn shell. ok there are not so many big differences
2. whence -v just tells me it's a function. ok that's nice to know but it doesn't tell me what's inside the function
3. typeset +f tells me which functions there are. ok that's nice to know but it doesn't tell me what's inside the functions
Kind regards, Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2004 11:29 PM
09-27-2004 11:29 PM
Re: Display code of a shell function?
ok all of your hints were useful and the last one was just what I wanted.
Thanks for your help, that's great!
Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2004 11:10 PM
09-28-2004 11:10 PM