79626429

Date: 2025-05-17 10:36:43
Score: 0.5
Natty:
Report link

When you double-click a .sh in Windows, Git Bash actually launches it via a wrapper (sh.exe or bash.exe -c …) rather than executing it directly. That wrapper injects extra frames (MSYS2 startup, the “–c” eval, etc.) into the call stack, so your hard-coded

bash

CopyEdit

caller_file="${BASH_SOURCE[2]}" caller_line="${BASH_LINENO[1]}"

no longer point at the TestFunction "11111" "22222" line (28) but at the very first source in your script (line 6) .

Solution 1: Run it from the Git Bash prompt

Open Git Bash and do:

bash

CopyEdit

./tester_copy.sh

This invokes bash.exe directly on your script (no wrapper), so the call stack is exactly

css

CopyEdit

ErrorReport → TestFunction → Main

and ${BASH_SOURCE[2]}tester_copy.sh, ${BASH_LINENO[1]} → 28 as you expect .

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): When you
  • Low reputation (1):
Posted by: saivihal