bash: distinguish between script invocation versus source

48 · Thiago Perrotta · Jan. 8, 2025, 1:42 a.m.
Summary
This blog post discusses how to prevent direct invocation of a bash script and ensure that certain variables are available in the current shell context when sourcing the script. It provides a solution using conditional checks in bash, alongside a personal anecdote about using ChatGPT for script improvement.