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'
3
  • Can you give an example of what you tried ?
    – matzeri
    Oct 21, 2016 at 19:11
  • 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
    Oct 21, 2016 at 19:37
  • I've added details...so do I really need to change the script?
    – carla
    Oct 21, 2016 at 20:04

1 Answer 1

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.

You must log in to answer this question.

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