Posix paths and shell commands

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Posix paths and shell commands

Post by Simon Knight » Thu Oct 31, 2019 3:40 pm

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
best wishes
Skids

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Posix paths and shell commands

Post by FourthWorld » Thu Oct 31, 2019 5:17 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

wsamples
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 262
Joined: Mon May 18, 2009 4:12 am

Re: Posix paths and shell commands

Post by wsamples » Thu Oct 31, 2019 6:57 pm

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.

Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Posix paths and shell commands

Post by Simon Knight » Fri Nov 01, 2019 9:04 am

Thanks for the conformation and the tip about using single quotes.

Simon
best wishes
Skids

Post Reply

Return to “Mac OS”