Jump to content

Variable not working inside Script Filter

Recommended Posts

It's a bit late, so I might just be doing something dumb...


But anyways, I have this code in my Script Filter:

#!/usr/bin/env bash

export PATH="$PATH:$node_path:/usr/local/bin:/usr/bin"

node $node_flags javascript-file.js comments "{var:task}"


And I'm getting this error:

Code 1: undefined:1

SyntaxError: Unexpected token t in JSON at position 1


I have an Alfred Variable Object assigning the `task` variable to a value, but I'm not sure how to use it.


Could I get some help? Thanks!!

Edited by forgetfulfellow
Link to comment
2 hours ago, forgetfulfellow said:

but I'm not sure how to use it


When Alfred runs a script or any code you’ve put in a Script box, its puts all your workflow variables in the process environment. {var:task} variable macros don’t work in Script boxes. Use the language’s mechanism for reading environment variables, instead. So in your case – bash – that’s just $task. Same as what you’re doing with $node_path by the looks of it.

Edited by deanishe
Link to comment

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...