newville / pyshortcuts

create desktop shortcuts to python scripts on Windows, Mac, or Linux
MIT License
101 stars 15 forks source link

MAC Shorcut doesn't work #59

Open Xueyi-Chen-David opened 10 months ago

Xueyi-Chen-David commented 10 months ago

I made a shortcut and set SCRIPT as shell script on Mac book and the shortcut doesn't work. However, if I modified /darwin.py:119 to #!/bin/sh (except #!/bin/bash), it can run successfully.

I don't know why this is happened....

newville commented 10 months ago

@Xueyi-Chen-David Can you give more precise details of what you did and the resulting shell file in Contents/MacOS?

If which shell is being used makes a difference, perhaps there is some difference in the Environmental Variables set for those shells on your system that affects the running of your script.

Xueyi-Chen-David commented 10 months ago

!/bin/bash

export EXE=/bin/bash export SCRIPT=/Users/david/Documents/Test/Test.sh export ARGS='' osascript -e 'tell application "Terminal" do script "'${EXE}\ /Users/david/Documents/Test/Test.sh\ '" end tell '

What I mean is that if I change the first line to other shell program except bash, this will work.

BTW, Run /tests directly on MAC book also didn’t work

newville commented 10 months ago

Does that mean that your "Test.sh" script runs differently from bash than it does from sh?

I guess I would say that I am not sure how we would know to use a different shell (like, what if someone wants to use zsh?).

What was the command used to create that shortcut?

Xueyi-Chen-David commented 10 months ago

Actually, When I double click the app, nothing will be happened (first line is #!/bin/bash), but if I change the first line into #!/bin/sh (or like dash, zsh...) it will work.

My python code is here: pyshortcuts.make_shortcut( desktopScriptPath, # /Users/david/Documents/Test/Test.sh name='Test', icon=ICONPath, description='Test', terminal=True, desktop=True, startmenu=True, executable='/bin/bash' )

newville commented 10 months ago

Does your "Test.sh" script run differently from bash than from sh?

In general, how would we know what shell to use? Like, you did sort of specify a shell - and it was "/bin/bash" - so that is very confusing.

Xueyi-Chen-David commented 10 months ago

Does your "Test.sh" script run differently from bash than from sh?

No different if I run "bash test.sh" or "sh test.sh".

But Actually, I try to run the test program "Timer" from the repo (test_pyshortcuts.py), it also didn't work when I double click the Timer.app. And I change the shebang to the others except bash, it works.

newville commented 10 months ago

@Xueyi-Chen-David The timer test works on macOS for me. I think that executing Contents/MacOS/ Githubissues.

  • Githubissues is a development platform for aggregating issues.