Why is the first command-line parameter in this Windows file association set apart?

Reading this answer to a more specific question, I wonder why the first argument is “kind of” set apart in this command line used to associate the .sh file extension:

"C:\cygwin\bin\bash.exe" -li "%1" %*

Isn’t it sufficient to just put %* there, i.e., leave out the "%1" – and won’t the script name itself appear as the first parameter in the drop-target script when using the proposed solution above?

Answer

If you pay attention closely, you observe that the first parameter goes through special processing, i.e. it is put between quotation marks. (The important part is the quotation mark that appears after the first parameter.)

Without the quotation mark, attempting to open C:\Script with long name.sh results in the equivalent of the following command being executed:

C:\cygwin\bin\bash.exe -li C:\Script

…which is faulty.

Attribution
Source : Link , Question Author : SomeDev , Answer Author : Community

Leave a Comment