Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAC Shorcut doesn't work #59

Open
Xueyi-Chen-David opened this issue Nov 14, 2023 · 7 comments
Open

MAC Shorcut doesn't work #59

Xueyi-Chen-David opened this issue Nov 14, 2023 · 7 comments

Comments

@Xueyi-Chen-David
Copy link

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
Copy link
Owner

@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
Copy link
Author

Xueyi-Chen-David commented Nov 14, 2023

#!/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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

Xueyi-Chen-David commented Nov 14, 2023

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
Copy link
Owner

@Xueyi-Chen-David The timer test works on macOS for me. I think that executing Contents/MacOS/<Script> must be running some user-specific shell initialization file -- maybe .bashrc or .zprofile or similar. I am not sure I can tell you much more than that....

Sorry, I'm not really seeing a problem with pyshortcuts here, at least not yet....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants