title: Get the name of the caller script in bash script
body: <p>Let's assume I have 3 shell scripts:</p>
  
  <p><strong>script_1.sh</strong></p>
  
  <pre><code>#!/bin/bash
  ./script_3.sh
  </code></pre>
  
  <p><strong>script_2.sh</strong></p>
  
  <pre><code>#!/bin/bash
  ./script_3.sh
  </code></pre>
  
  <p>the problem is that in <code>script_3.sh</code> I want to know the name of the caller script.</p>
  
  <p><em><strong>so that I can respond differently to each caller I support</strong></em></p>
  
  <p><em>please don't assume I'm asking about <code>$0</code> cause <code>$0</code> will echo <code>script_3</code> every time no matter who is the caller</em></p>
  
  <p>here is an example input with expected output</p>
  
  <ul>
  <li><p><code>./script_1.sh</code> should echo <code>script_1</code></p></li>
  <li><p><code>./script_2.sh</code> should echo <code>script_2</code></p></li>
  <li><p><code>./script_3.sh</code> should echo <code>user_name or root or anything to distinguish between the 3 cases</code>?</p></li>
  </ul>
  
  <p>Is that possible? and if possible, how can it be done?</p>
  
  <p><strong>this is going to be added to a <code>rm</code> modified script... so when I call <code>rm</code> it do something and when <code>git</code> or any other CLI tool use <code>rm</code> it is not affected by the modification</strong></p>