Make a cygwin script shortcut that ask for parameters

0

I created a script for cygwin and set a shortcut as explained in the end of this tutorial.

Altough, my script has to receive variable parameters and the way it was set either it runs as if no parameters were passed or if I set anything after the script path it considers it as literal parameter.

Consider a script (echo.sh) like this:

#!/bin/bash    
echo "this"$1
sleep 30

The target in my shortcut:

C:\cygwin64\bin\bash.exe --login -i '/cygdrive/c/cygwin64/echo.sh'

When I click in the shortcut it already prints 'this' and sleeps. I tried:

C:\cygwin64\bin\bash.exe --login -i '/cygdrive/c/cygwin64/echo.sh $1' #file not found
C:\cygwin64\bin\bash.exe --login -i '/cygdrive/c/cygwin64/echo.sh' $1 #prints 'this$1'

carla

Posted 2016-10-21T18:39:09.317

Reputation: 113

Can you give an example of what you tried ? – matzeri – 2016-10-21T19:11:40.693

Shortcuts cannot use variable parameters. You should modify your script to ask for the values to use or read them from a file as appropriate. Note it is actually very unclear what you are actually trying to do. – DavidPostill – 2016-10-21T19:37:40.037

I've added details...so do I really need to change the script? – carla – 2016-10-21T20:04:28.630

Answers

0

As already stated in the comments, shortcuts cannot handle variables.

You can create a batch script (script.cmd), that receives an argument and invokes Cygwin.

C:\cygwin64\bin\mintty.exe /usr/bin/bash --login "/cygdrive/c/cygwin64/echo.sh" %1

You can also drag and drop an icon to your script.cmd, and it receives the path of the dropped file as an argument. You have to take care of Windows <-> Cygwin path translations (cygpath) however.

Joe

Posted 2016-10-21T18:39:09.317

Reputation: 141