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
bash -c Task.sh
count as running inside a script? If not, why not?Value=$(Task.sh)
, or also a script that just runsTask.sh
? Also, is there some particular reason forTask.sh
to behave differently in these situations? Knowing the background might help in finding a suitable solution.Task.sh
intoTask.sh --clipboard
, or so. But you could do it the other way around too, since at least the argument needs to be added to the script only once.