0

Been trying to work this out this morning and beginning to wonder if this is even possible.

When launching a shell script through Finder, either by using the extension .command or opening .sh files in Terminal, the following command is executed:

Macbook-Pro:~ /Users/mulquin/Desktop/test/Path\ With\ Spaces/run.sh ; exit;
Could not open input file: /Users/mulquin/Desktop/test/Path

Trying it with quotes instead of escape characters yields the same result

Macbook-Pro:~ "/Users/mulquin/Desktop/test/Path With Spaces/run.sh" ; exit;
Could not open input file: /Users/mulquin/Desktop/test/Path

The users this is intended for are not tech savvy so asking them to open Terminal, browse to a directory and ./run.sh is unfortunately not an option.

I had a look at Platypus but the script location will be dynamic as the users will be running it from their desktops or other location they choose.

Has Apple really not noticed this issue or am I doing something wrong?

7
  • 1
    I don't know much about the proper use of delimiters but the second method with double quotes certainly should work. I have used it many times and it always worked. That being said, I have to assume you are doing something wrong but I don't see it!
    – Natsfan
    Jul 31 '20 at 1:49
  • 1
    what machine and what version of the system are you running?
    – Natsfan
    Jul 31 '20 at 1:50
  • 1
    Have you tried putting quotes only around "Path With Spaces"?
    – Natsfan
    Jul 31 '20 at 1:52
  • @jmh your assumption was correct, I erroneously believed the error message was from Mac OS X executing the script. The error actually came from inside my script where I forgot to enclose the command in quotes. D'Oh! Thanks for helping me out.
    – mulquin
    Jul 31 '20 at 2:08
  • 1
    my pleasure. glad i could help...
    – Natsfan
    Jul 31 '20 at 2:09
2

It turns out I was doing something wrong.

I erroneously believed the error message was caused by Mac OS X executing the script.

The reason this error was appearing was because inside my script I was executing something without escaping the space. Woopsie!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .