Page 1 of 1

Posix paths and shell commands

Posted: Thu Oct 31, 2019 3:40 pm
by Simon Knight
Hi,

I don't have much experience with the Terminal or Shell commands but I am creating a small utility that passes a file name to a shell command. I have discovered that the Livecode Shell command fails if the filename includes spaces. Also I'm also sure that there are other characters that the OS allows in filenames that the shell does not. I appear to have solved the problem by wrapping the file name in quotes e.g. :

Code: Select all

put tShellFileSpec & " -p " & tProjectName & " " & "/Users/skids/Temp/" & quote & "20150505_110851_P1000252 copy.RW2" & quote into tShellCommand
Is this the correct, best and robust method of dealing with characters that only OS X allows (when compared with the UNIX underpinnings) or is there a better way ?

best wishes
Skids

Re: Posix paths and shell commands

Posted: Thu Oct 31, 2019 5:17 pm
by FourthWorld
Yes, bash params like paths that may include spaces can be quoted to have bash treat it as a single param, just as with LC itself.

Re: Posix paths and shell commands

Posted: Thu Oct 31, 2019 6:57 pm
by wsamples
You should be able to use single quotes instead of double quotes to wrap the path. This obviates the need to wrestle with " & quote " syntax.

Re: Posix paths and shell commands

Posted: Fri Nov 01, 2019 9:04 am
by Simon Knight
Thanks for the conformation and the tip about using single quotes.

Simon