vitor Posted November 20, 2013 Share Posted November 20, 2013 (edited) Let’s say I have this test.rb ruby file (notice I’m not using a single quote (') but an apostrophe (’)) string = "It’s a string" puts string I can run this and get the expected output $ /usr/bin/ruby test.rb It’s a string However, in Alfred, if I have a Run Script that has the equivalent, it completely chokes and does nothing, other than the error sound. Using this as intended for it’s final version (having a hotkey that’ll pass selected text), we don’t even get the sound, just nothing.Using OS X 10.9 and Alfred 2.1.1(227). Edited November 20, 2013 by Vítor Link to comment
jdfwarrior Posted November 22, 2013 Share Posted November 22, 2013 Let’s say I have this test.rb ruby file (notice I’m not using a single quote (') but an apostrophe (’)) string = "It’s a string" puts string I can run this and get the expected output $ /usr/bin/ruby test.rb It’s a string However, in Alfred, if I have a Run Script that has the equivalent, it completely chokes and does nothing, other than the error sound. Using this as intended for it’s final version (having a hotkey that’ll pass selected text), we don’t even get the sound, just nothing.Using OS X 10.9 and Alfred 2.1.1(227). Hey man, I looked around at this the other day for Andrew and here's a little bit of info that I came up with. I'd enjoy to hear your feedback on it so maybe we can figure out a solution for this... Anyway.. Looking at the sample script from above, the character that you are referencing as being an apostrophe is actually a (according to the character viewer) a single right quotation mark (unicode character U+2019). An apostrophe is unicode character U+0027. Using the script above, if I manually encode the character, it works fine. So, if I change the right single quotation mark character to \u2019 then it works normally. This makes me wonder if it's some form of encoding issue with the script area in Alfred. If you look at the change log for Alfred 2.1.1.. 2.1.1 18th Nov 2013 • Add native tag support, with new ‘tags’ keyword which uses 'AND' logic for multiple keywords • Improved layout for file search prefs for the new tag option • Better support for OS X Mavericks multi screen, with new appearance option to “Show Alfred on Active Screen” • In the Contacts Viewer, show addresses in Apple Maps by default, falling back onto Google Maps if Apple Maps isn't available • Add Apple Maps into default web searches for users on Mavericks • Show workflow image in notification in Mavericks with checkbox to disable in Advanced prefs • Improvements to the iTunes AppleScript integration • Fix some preference layout issues in Mavericks • Turn off OS X auto substitution in Alfred's script editor fields e.g. smart quotes • Fix escaping of ! in folder names for 'Open Terminal Here' file action • Improved selected item mouse hover behaviour in default results • More resilient inline definitions for non EN locales • Stop trailing / being added when copying an optionally escaped path to clipboard • Update tool chain and to using Xcode 5, improve build scripts The entry that I made bold was actually something similar. In a fresh install of Mavericks, the substitutions were on in the Keyboard prefs. When I tried to type a single or double quote in the script editor area, they were the substituted versions and caused the script to not work properly. As a solution, Andrew disabled substitutions in the script editor but that doesn't mean that if you copied and pasted the character in there or something that it can't be there. So.. I'm wondering if this is the same issue. As mentioned, if you have to have this character in the script, you could encode it manually and it would work normally. Link to comment
vitor Posted November 22, 2013 Author Share Posted November 22, 2013 the character that you are referencing as being an apostrophe is actually a (according to the character viewer) a single right quotation mark I saw that too, but it’s actually what OS X corrects to, and it’s also the character you copy from the wikipedia page on the apostrophe. Either way, in this case is not much of a difference, it’s still a character not being interpreted. This makes me wonder if it’s some form of encoding issue with the script area in Alfred. If you look at the change log for Alfred 2.1.1.. (…) • Turn off OS X auto substitution in Alfred's script editor fields e.g. smart quotes Yep, seems about right. As mentioned, if you have to have this character in the script, you could encode it manually and it would work normally. No can do, that really does not solve the problem. As I mentioned, the intended way for this to work is on a workflow that’ll have text passed into it from a hotkey. This means that I have no control about what the text will be, since users can pass whatever they want (it’s a parser). I certainly understand the need for that change, but it will potentially break some workflows, and any future ones that depend on interpreting outside text. The problem here is that the substitution is being made inside {query}, and that really should not happen in that case, only to the text directly and specifically written inside the text area. Link to comment
Andrew Posted November 22, 2013 Share Posted November 22, 2013 Let’s say I have this test.rb ruby file (notice I’m not using a single quote (') but an apostrophe (’)) string = "It’s a string" puts string I can run this and get the expected output $ /usr/bin/ruby test.rb It’s a string However, in Alfred, if I have a Run Script that has the equivalent, it completely chokes and does nothing, other than the error sound. Using this as intended for it’s final version (having a hotkey that’ll pass selected text), we don’t even get the sound, just nothing.Using OS X 10.9 and Alfred 2.1.1(227). As this is working correctly in bash, I suspect it's actually something to do with the default encoding changing in Ruby for Mavericks similar to this issue: http://www.alfredforum.com/topic/3173-ruby-workflows-in-mavericks/?p=19605 There may be a mix between Ruby running as ASCII by default and the UTF8 normalisation. I am going to move this to the Workflow Help sub-forum to see if somebody else with a better understanding of Ruby that I have can help you work out what's going on. Cheers, Andrew Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now