Jump to content

JXA adds line feed in the end of output


Modi34

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]
Link to comment
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.

Link to comment
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
Link to comment
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
Link to comment
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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...