How to access folder form a .tool application I can create a clickable script, by changing the .sh extension to a .tool (or .command) one. However when I do this, the paths that I have in my script break.

I am trying to run a dotnet core application and my shell script is simple:

#!/bin/bash
dotnet ${PWD}/OUTPUT/Calculator.dll 


Where OUTPUT is the name of the folder with the dotnet release files in it.

if the script is a .sh file, the script runs, but then the end user has to go to the terminal and type in ./runscript.sh or whatever I call it. 

The other thing I noticed was that it looks like the output of the app removes any spaces changing:

dotnet ${PWD}/OUTPUT/Calculator.dll 

into:

dotnet-${PWD}/OUTPUT/Calculator.dll 

How do I make it so that my paths in the script don't break when I change it into a .tool extension?



UPDATE:

As the answer suggested I have tried both:

dotnet ~/OUTPUT/Calculator

This results into:


  No executable found matching command "dotnet-/Users/jeff_mba/OUTPUT/Calculator"


and:

dotnet\ ~/OUTPUT/Calculator

which results into:


  /Users/jeff_mba/Projects/calctest/runcalc.command: line 3: dotnet ~/OUTPUT/Calculator: No such file or directory


So there is a spacing issue, but if I escape the space it still says the project is not found

But as per the screenshot it really does exist.
You simply have to supply the full path to the DLL in the script.

When you run the script from Terminal.app, the PWD environment variable contains the path to the folder where you're currently placed. I.e. if you use cd to move to other folders, the PWD environment variable is automatically updated to match.

When you're using the GUI and double-clicking an icon, you're not really "in" a specific folder at the time. So the same concept of a PWD environment variable tracking your movements do not make sense.

Instead simply supply the full path in the script, such as:

dotnet ~/OUTPUT/Calculator.dll


Here ~ means that currently logged in user's home folder.