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

Escaping first character of title, subtitle, message #134

Open
derek121 opened this issue Jun 11, 2015 · 1 comment
Open

Escaping first character of title, subtitle, message #134

derek121 opened this issue Jun 11, 2015 · 1 comment

Comments

@derek121
Copy link

The usage message on the command line mentions that in some cases the first character of the message needs to be escaped (but only mentions open bracket as one of those characters- the less-than character is another one). The command fails in those cases if message is not escaped.

I've found similar behavior with title and subtitle, although for those, the notification does get made, with those fields simply missing.

I'm seeing that simply adding a \ as the first character of the title, subtitle, or message, regardless of what follows, is suitable. However, if using an environment variable instead of literal text, the $ is what gets escaped, and is included as a literal $. Using a double backslash, \, prevents that, and also works for literal text.

For example:

Returns error message:

$ terminal-notifier -title "the title" -message "[msg]" -subtitle "sub"
$ export MSG="[msg]"
$ terminal-notifier -title "the title" -message "$MSG" -subtitle "sub"

Works as expected:

$ terminal-notifier -title "the title" -message "\\[msg]" -subtitle "sub"
$ export MSG="[msg]"
$ terminal-notifier -title "the title" -message "\\$MSG" -subtitle "sub"

Puts up notification, ignoring title (or subtitle, if done with subtitle instead of title):

$ terminal-notifier -title "[the title]" -message "msg" -subtitle "sub"
$ export TITLE="[msg]"
$ terminal-notifier -title "$TITLE" -message "msg" -subtitle "sub"

Works as expected:

$ terminal-notifier -title "\\[the title]" -message "msg" -subtitle "sub"
$ export TITLE="[msg]"
$ terminal-notifier -title "\\$TITLE" -message "msg" -subtitle "sub"

Given this behavior, at the very least, mention should be made in the README of it somehow. Or better, tweak the code as needed (adding the ?). I'd be happy to submit a PR with a README addition if desired, but am not familiar enough with the code, or Ruby, to dig in there.

I bring this up because I was having issues when the first character happened to be a <.

@julienXX
Copy link
Owner

Thanks for bringing this up. Looking into it to see what can be done.

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

No branches or pull requests

2 participants