Jump to content
Modi34

JXA adds line feed in the end of output

Recommended Posts

Hello, I use a simple jxa for getting url from devonthink

SYK31LM.gif

this is the code Im using

function run(argv) {
var q=argv[0].split('/'),q=q[q.length-1].split('.')[0];
var qq=Application('/Applications/DEVONthink Pro.app').getRecordWithUuid(q).url();
  return qq
}
 
But it adds %0A in the end of every link - this is not a script bug - this is an alfred 3 bug
 
osx 10.11.5, alfred v 3.0 [652]

Share this post


Link to post
Share on other sites

%0A is a return character, probably produced by your script. I had the same.

To fix this you can use the new "Transform" function of Alfred to trim whitespaces. That will get rid of it.

 

Btw what appswitcher are you using there? The circle you use to get back to alfred.

Share this post


Link to post
Share on other sites

%0A is a return character, probably produced by your script. I had the same.

To fix this you can use the new "Transform" function of Alfred to trim whitespaces. That will get rid of it.

 

Btw what appswitcher are you using there? The circle you use to get back to alfred.

thx ! - that helped me)

my app switcher is https://itunes.apple.com/ru/app/ring-menu-shortcut-to-your/id934212116?mt=12&ign-mpt=uo%3D4 - ring menu - http://ring-menu.com/

Edited by Modi34

Share this post


Link to post
Share on other sites

 

I checked the script - this is an alfred bug - here is an example

 

 

I added a string http://tryhaskell.org/into return statement and alfred added a line feed

 

 

Something that Andrew shoulda take a look at then. For now you can add under Right Click → Utilities → Transform and trim whitespaces

Now i gotta have to check out ring menu :D

Edited by FroZen_X

Share this post


Link to post
Share on other sites

I checked the script - this is an alfred bug - here is an example

 

This is a quirk of osascript which adds a newline to any output.

 

Alfred actually runs all scripts in the same way, so a simple way to see what is being output from a script is to wire a keyword -> run script -> debug utility. Set the keyword to require arguments and show Alfred's debug panel. You can then change the script type (and get Alfred's default template) to see each output from the scripts. All of the script types don't add a new line except osascript.

 

You'll also notice that in bash / zsh, the default script adds -n to the output to prevent the newline being added.

 

One option would be for me to always trim outputs from the script output, but this would inevitably cause regression issues as some workflows may expect a newline being output.

 

Cheers,

Andrew

Share this post


Link to post
Share on other sites

×
×
  • Create New...