From ee9045dc00c332ff4d81ed6fcef6d2cce1cec62d Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Wed, 14 Feb 2024 17:03:42 +0300 Subject: [PATCH] Bash : How to check for script being sourced. --- help/linux/bash/script/CheckIfSourced.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 help/linux/bash/script/CheckIfSourced.md diff --git a/help/linux/bash/script/CheckIfSourced.md b/help/linux/bash/script/CheckIfSourced.md new file mode 100644 index 0000000..270de9a --- /dev/null +++ b/help/linux/bash/script/CheckIfSourced.md @@ -0,0 +1,5 @@ +# Bash check for sourced file. + +```bash +(return 0 2>/dev/null) && sourced=1 || sourced=0 +```