CJK Posted January 22, 2019 Share Posted January 22, 2019 The Run Script action, particularly relevant to osascript, appears to return the result of the script as text that is terminated with a line break character. This causes problems when the script returns a file path, which gets fed into the subsequent node of the workflow that is expecting to receive a file path that points to an existing file, but instead receives a file path that points to a non-existent file because of the extra character in its name. https://transfer.sh/LEmG3/Bug Report.alfredworkflow The workflow demonstrates the phenomenon. It simply displays an osascript output surrounded by quotes to visualise the string in its entirety. The code used in the `osascript` is: on run return "~/Downloads" end run This might not technically be a bug, per se, as I'm guessing the Run Script actions all execute a script by way of a shell command, and therefore it may be that the osascript command itself is returning this output rather than something Alfred is doing. That said, when I run the following command in Terminal: osascript -e 'return "~/Downloads"' | wc -l it reports that the output does only contain a single line. Link to comment
Andrew Posted January 22, 2019 Share Posted January 22, 2019 @CJK Alfred doesn't process the output of a Run Script object in any way, and osascript non-optionally appends a newline to any output (which could be seen as an osascript bug, but I suspect this behaviour will never change). You have a couple of options: 1. If you switched your script to bash, then use echo -n for output, you'll get the output as expected. 2. Add a Transform utility object after your Run Script set to trim the output. This will remove the newline from your osascript. This has come up before, and my opinion remains that Alfred shouldn't automatically process the output of ant Run Script objects (e.g. to trim), as this would lead to more unexpected behaviour than not. Cheers, Andrew [moving to workflow help]. xilopaint 1 Link to comment
Andrew Posted January 22, 2019 Share Posted January 22, 2019 I just thought... it's worth adding that you do actually see the appended newline from osascript -e 'return "~/Downloads"' in Terminal. When using bash and echo -n, the next command is immediately after your output. Cheers, Andrew CJK 1 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