Cmder bash script executing

后端 未结 6 1069
太阳男子
太阳男子 2021-02-13 05:35

I created basic script in Windows.

#!/bin/bash

echo Hello

I am using Cmder, ConEmu derivative. I tried to change the priviliges with chmod, bu

6条回答
  •  暖寄归人
    2021-02-13 05:57

    If you don't have time jump to The conclusion below:

    TL:DR: Here my toying with "Cmder > bash" on Windows to create a Global script:

    I've created a external script:

    a@DESKTOP /c/Scripts/
    λ vi test.sh
    

    with the content

    #!/bin/bash
    echo 'Can you see me now?'
    

    it can be executed from the same folder:

    a@DESKTOP /c/Scripts/
    λ ./test.sh
    Can you see me now?
    

    on creating a simbolink link:

    λ ln -s /c/Portables/Scripts/GlobalesBash/test.sh /bin/mytest
    

    it seems to work fine calling it with just the name:

    λ mytest
    Can you see me now?
    

    but if the original file gets modified:

    λ cat test.sh
    #!/bin/bash
    echo 'Yes, I see you'
    

    the changes are not reflected using the link:

    λ mytest
    Can you see me now?
    

    The conclusion:

    so the best option is creating the script directly on the folder /bin:

    λ cd /bin
    λ vi aloha
    λ cat aloha
    echo 'aloha!!!'
    

    and #!/bin/bash isn't even necessary with Cmder on Windows, and it gets executed successfully from everywhere in the Cmder bash:

    λ cd /c
    a@DESKTOP /c
    λ aloha
    aloha!!!
    

提交回复
热议问题