[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

bash question: identify line number of function call



in bash, is it possible to identify the line number of a script, from
where a function has been called?

for instance, using the hypothetical print_line_number function, which
i am looking for:

  1  #!/bin/sh
  2
  3  function myfn()
  4  {
  5    echo -n "this function has been called from line number #"
  6    print_line_number
  7  }
  8
  9  myfn
  10 
  11  exit 0

would print

"this function has been called from line number #9"

any clues? i'd hate to have to grep the linenumbered source file
itself for the function name. seriously.

martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:"; net@madduck
-- 
an avocado-tone refrigerator would look good on your resume.



Reply to: