Change behavior of bash script if executed from another script
0
votes
2
answers
216
views
I have a script (say
Task.sh
) (with executable permission):
Pseducode:
if [[ Not called from inside a script ]]; then
echo 'Not called from inside a script'
else
echo 'Called from a script'
fi
---
I have a script say Main.sh
(with executable permission):
Value=$(Task.sh)
echo "${Value}"
---
# Expected Outcome
$ Task.sh
Not called from inside a script
$ Main.sh
Called from a script
# Help Request
Please suggest what conditional to put in the pseducode for Task.sh
Asked by Porcupine
(2156 rep)
Oct 3, 2023, 08:26 PM
Last activity: Oct 7, 2023, 10:53 AM
Last activity: Oct 7, 2023, 10:53 AM