Can a New Shell be reused?

Hello All.

A quick question.

If I have a new shell to run a command like:

var myShell as New Shell
myShell.Execute (“ls -l”)

but then I want to run another shell Command AFTER that one is executed like

kill cfprefsd

Do I have to create a new shell for that, or can I reuse my myShell variable?

Regards

To send several commands to the same shell, you should use the interactive mode. Check the docs on how to use it.

I would recommend you use a new shell. Code you execute in a shell may make modifications to the shelf’s environment that affect how subsequent executable code behaves.

And that’s sometimes the intention, keeping track of current affected environment, as env vars for example, and for those cases, interactive will help them.

But I agree that the most used method is creating a new shell and firing it, just it.

Yeah. If he’s asking the question, the answer is “new shell”. He wouldn’t be asking if he was looking for that behavior.

He asked exactly that, “reuse the shell”.

Precisely my point.

Precisely my answer.

:laughing:

4 Likes