I wrote a lot of bash scripts that should work with the current bash session, because I often used fg
, jobs
, etc.
I always starts my scripts with . script.sh
but one of my friends startet it with ./script.sh
and got error that fg
"couldn't be executed".
Is it possible to force a . script.sh
or anything else what I can do to prevent errors? Such as cancel the whole script and print an error with echo
or something else.
Edit:
I think bashtraps
have problems when executing sourced
, is there any way to use fg
, jobs
and bashtraps
in one script?