• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Space in POSIX path/Terminal shell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Space in POSIX path/Terminal shell


  • Subject: Re: Space in POSIX path/Terminal shell
  • From: Jon Pugh <email@hidden>
  • Date: Fri, 4 Apr 2003 21:01:08 -0800

At 5:28 AM +0200 4/5/03, Philippe GRUCHET wrote:
>>URIs MUST NOT HAVE SPACES
>>
>>You can try a script that will actually produce a noticeable result:
>>open location "file:///System/Library/CoreServices/Help Viewer.app"
>
>Yes!
>But this line below also works, and with a space character in the last item:
>
>open location [no break]
>"file:///Users/philippe/Library/ScriptingAdditions/Jons Commands.osax"
>--> open its dico in Apple's SE.
>
>Do you confirm?

OK, so the "must not" was a little strong. URI's aren't supposed to have unescaped characters, but plenty of programs will let you get away with them.


>I get the same problem in a Terminal shell window to access to a program ("MathKernel") inside a local application package ("Mathematica 4.2.app").
>
>The original string path format is:
>
>":Applications:Maths:Mathematica 4.2.app:Contents:MacOS:MathKernel"
>
>If I type in the Terminal after [bla bla ~] philippe%
>/Applications/Maths/Mathematica 4.2.app/Contents/MacOS/MathKernel
>
>Or:
>
>/Applications/Maths/Mathematica 4.2.app/Contents/MacOS/MathKernel

Unix shells, of which the Terminal uses one, typically bash these days, require a different kind of escaping for spaces and other special characters. This is completely unrelated to URIs.

The simplest solution is to quote the path, with either single or double quotes. Both work, as long as they match. For example, these work:

"/Applications/Maths/Mathematica 4.2.app/Contents/MacOS/MathKernel"
'/Applications/Maths/Mathematica 4.2.app/Contents/MacOS/MathKernel'

You can also place a backslash in front of a single character to escape it. Like so:

/Applications/Maths/Mathematica\ 4.2.app/Contents/MacOS/MathKernel

These are particular to the shell you are using, and passing commands from AppleScript to "do shell script" can cause you to need multiple levels of escaping in order to make it through the various layers. In these cases, experimentation and a clue go a long way. ;)

Hopefully that helps some.

Jon
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Space in POSIX path/Terminal shell (From: Philippe GRUCHET <email@hidden>)

  • Prev by Date: Re: Space in POSIX path/Terminal shell
  • Next by Date: Re: Print to PDF under OS X and 9.2
  • Previous by thread: Re: Space in POSIX path/Terminal shell
  • Next by thread: Re: Space in POSIX path/Terminal shell
  • Index(es):
    • Date
    • Thread