Skip to content

About the mysterious difference between open from terminal and a browser like Chrome. #6

@ryuheechul

Description

@ryuheechul

While this is not a direct issue with this repo itself, I think documenting this and being searchable here might help people to figure out what to do with this mysterious behaviour.


So things like below similar to the one from current README.md worked with open but not with Chrome for me.

on open location this_URL
	do shell script "emacsclient \"" & this_URL & "\" && open -a Emacs"
end open location

And if you debug this by something like below. You don't really see the difference yet.

on open location this_URL
	do shell script "echo '" & this_URL & "' >> ~/tmp/debug-org-protocol"
end open location

But if you pipe it via base64 you might see a strange difference especially with a long enough this_URL

Try org-protocol://find-file:///Users/my-user/my-folder/my-file with both open and Chrome.

# tail -f ~/tmp/debug-org-protocol

# with `open` - it results in 2 lines - I don't know why
b3JnLXByb3RvY29sOi8vZmluZC1maWxlOi8vL1VzZXJzL215LXVzZXIvbXktZm9sZGVyL215LWZp
bGUK
# with Chrome - it prints in one line - expected
b3JnLXByb3RvY29sOi8vZmluZC1maWxlOi8vL1VzZXJzL215LXVzZXIvbXktZm9sZGVyL215LWZpbGUK

However, if you wrap the whole script with zsh now the Chrome's behaviour follows the same as zsh and

on open location this_URL
	do shell script "zsh -c \"echo '" & this_URL & "' | base64 >> ~/tmp/debug-org-protocol\""
end open location
# with `open` - it stays the same
b3JnLXByb3RvY29sOi8vZmluZC1maWxlOi8vL1VzZXJzL215LXVzZXIvbXktZm9sZGVyL215LWZp
bGUK
# with Chrome - it follows `open` now
b3JnLXByb3RvY29sOi8vZmluZC1maWxlOi8vL1VzZXJzL215LXVzZXIvbXktZm9sZGVyL215LWZp
bGUK

Same goes for org-protocol and now it is being recognized with Chrome as well with a code like below.

on open location this_URL
	do shell script "zsh -c 'emacsclient \"" & this_URL & "\" && open -a Emacs'"
end open location

Also, if I used bash instead of zsh, it didn't work.

Hope this is helpful for some people!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions