I have a library that accepts plugins. The plugins are shell scripts. I want to prevent the plugins from changing the current working directory for any command in the script.
One thing I could do is somehow prevent changing directory by making
cd or similar into some sort of no-op. This seems like a bad-idea and perhaps tyrannical / too heavy-handed.
The other thing I could do is force the plugins to pass a suite of tests, and in those tests somehow detect a change of directory in the script. (And fail the test if a change directory command was issued).
My question is - is there a good way to prevent cd'ing (and similar commands... what are they?), or detecting a cd within a shell script?