Condition for checking if bash script has been sourced

Опубликовано: 24 Январь 2025
на канале: Dipesh Majumdar
63
3

Suppose you have written a bash script for a complex manual activity and got a lot of praise from your team members... however, this script only runs as expected if it is sourced. Is there a check that can be present in the script which will throw an error if the script is not being sourced and being executed directly.