@raynovich said:
Does ofelia take over the "terminal" or some other function for Pure Data if created?
TL;DR Probably the best solution is for you to construct the commands with full paths, pointing exactly where you want, and do not rely on the current working directory.
I.e. not cd xxx/yyy/zzz && ls
, but ls xxx/yyy/zzz
.
Why?
"Shell" functions (as I understand it -- maybe it's different in some programming environments, but this is my observation) generally don't persist their state.
That is, if you open a terminal window, there is one shell, and every command operates on the same shell. cd
changes the current working directory of the shell, and the next command remembers the new cwd.
An object like [shell] is like opening a new terminal window for every command. Every invocation starts from scratch. So you should not expect it to work if you ask shell to first cd, then ls. (You said this worked, but I was not able to get that behavior on my machine.)
SuperCollider has a couple of ways to do it that illustrate the issues involved.
"ls".unixCmd; // user home
"cd tmp".unixCmd; // no output, OK
"ls".unixCmd; // still user home
The cd
did not affect the second ls
-- because it's like: terminal window 1, ls
; terminal window 2, cd
; terminal window 3, ls
and why would you expect window 2 to affect the behavior of window 3?
Many shells, when parsing the typed input, can handle a series of commands separated by &&
:
"cd tmp && ls".unixCmd; // lists ~/tmp, OK!
But this is a parsing feature. If a backend issues the command in a different way -- as an array of strings, where the first string is the command and the other strings are arguments, one by one -- this bypasses the parser (because the arguments are already parsed into the array), and the &&
trick no longer works.
"cd tmp && ls".split($ ).postcs.unixCmd;
[ "cd", "tmp", "&&", "ls" ]
(and no `ls` listing)
[shell], as far as I can see, works in this second way. A message like ls tmp
works only if it's a list of two symbols. If you try to make it a single command string -- ls\ tmp
-- then it fails, because there is no system command named l-s-space-t-m-p. (In SC, "ls tmp".unixCmd
runs the command through the shell's parser, which splits a string into command-and-argument. That usage isn't supported in [shell]. Maybe it's supported in [command] but I didn't take a look.)
hjh