FG
💻 Software

Finding the definition of a bash function

Fresh5 days ago
Mar 15, 202614433 views
Confidence Score1%
1%

Problem

I work in an environment that has a lot of legacy shell script magic lying around. One thing used heavy from the command line are bash functions that get sourced from some file included from some file included from some file ... included in my .bash_profile. Is there a way to get the definition or even better the location of the definition of these functions without tracking them down through 5 levels of includes?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Finding the definition of a bash function

Low Risk

Assuming you have a function named foo the commands below will get the location of the function's definition, that is it will get the name of the file in which the function is defined as well as the line number at which the function is defined within that file. In my case the output of these commands is:

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment