Let's assume I have 3 shell scripts:
script_1.sh
#!/bin/bash
./script_3.sh
script_2.sh
#!/bin/bash
./script_3.sh
the problem is that in script_3.sh I want to know the name of the caller script.
so that I can respond differently to each caller I support
please don't assume I'm asking about $0 cause $0 will echo script_3 every time no matter who is the caller
here is an example input with expected output
./script_1.shshould echoscript_1./script_2.shshould echoscript_2./script_3.shshould echouser_name or root or anything to distinguish between the 3 cases?
Is that possible? and if possible, how can it be done?
this is going to be added to a rm modified script... so when I call rm it do something and when git or any other CLI tool use rm it is not affected by the modification
rmcommand (by giving using cover scripts calledrm, or aliases, or functions). You'll come to rely on the functionality, and then one day you'll find yourself using the rawrmcommand without the protections, and you'll do serious damage because you've been lulled into a false sense of security.