LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-16-2017, 09:03 AM   #16
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51

Quote:
Originally Posted by hydrurga View Post
Yes, but for a start, Bash isn't the only shell out there.

Whereis and Which simply search specific paths for specific filenames. To search for user-defined shell functions, you would have to start parsing shell-dependent start-up scripts in all the different filesystem locations that those scripts can exist, and parsing all the different forms/syntax that the functions can be written in. It could very quickly become unwieldy and unsustainable.
I am not sure to follow your ideas.

Bash is not the only shell out, fine. As I asked in the post I just sent, are declare/typeset present in other shells? Is it present in sh, for example? Yes would be my guess, because there are two names for the same command.

And I really cannot understand your second paragraph. Why do you think we need to search many places? It is just what the shells do for us everytime we type any command (indirectly, since they are defined at login, shell creation or by eventual scripts or commands)!

Last edited by dedec0; 04-16-2017 at 12:26 PM.
 
Old 04-16-2017, 01:00 PM   #17
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
declare is Bash-specific. typeset was developed in ksh but is also supported in Bash.

To recapitulate, which and whereis are currently shell-agnostic. In order to incorporate user-defined shell functions, they would have to take into account all the shells that exist in Linux with all their different ways of defining these functions.
 
Old 04-16-2017, 01:32 PM   #18
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
@hydrurga: I see. So the simpler sh does not have a way to list defined functions? And other shells (like tcsh) should have yet other ways to do the same?

Further, have you seen my post about making a shell function to do this job? What do you think of it?
 
Old 04-24-2017, 05:32 PM   #19
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,789

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Code:
set
dumps functions and aliases and settings, in all sh-style shells.
Code:
type sed
works for functions as well, in all sh-style shells.
Note that the which command comes from csh and might show csh-aliases (from your .cshrc) but never sh-aliases and functions!
 
1 members found this post helpful.
  


Reply

Tags
bash



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SED - minor changes work - Larger doesn't (working and non working code included) Nimoy Programming 17 09-22-2007 04:34 PM
I am learning sed / grep working and am stuck with a problem chris_looks Linux - Newbie 12 08-14-2007 11:13 AM
I am learning sed / grep working and am stuck with a problem chris_looks Linux User Groups (LUG) 2 08-06-2007 01:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration