Niclas Posted November 15, 2017 Posted November 15, 2017 I have a simple workflow, that checks if a file exists, and shows a notification with the content if it does, and a Large type ERROR, if it doesn't. I think I misunderstand something with how filter works. The script looks like this: FILE="/Users/niclas/test.txt" if [ -f "$FILE" ]; then cat $FILE else echo ""; fi Top filter: Only continue if {query} is not equal to (empty) Bottom filter: Only continue if {query} is equal to (empty) The notification looks like: Read OK {query} The problem is, it always shows the first one, even if the file doesn't exist. I also tried make it output 0, and "Only continue if {query} is equal to 0", but with the same results. I also tried a regex (0)+, it didn't work either. What am I doing wrong? I've attached the workflow here: Workflow Thanks!
Niclas Posted November 15, 2017 Author Posted November 15, 2017 Hmm, it seems to work when I didn't echo anything at all, by just removing the else part. So echo probably outputs a newline or something. But why didn't it work with echo "0" and setting the filter to match on "0"? Is it something with a new line in the script?
deanishe Posted November 15, 2017 Posted November 15, 2017 7 hours ago, Niclas said: Hmm, it seems to work when I didn't echo anything at all, by just removing the else part That's the right solution. 7 hours ago, Niclas said: So echo probably outputs a newline or something. It does. Use echo -n to suppress the trailing space. 7 hours ago, Niclas said: Is it something with a new line in the script? Alfred tries to remove extraneous whitespace, so it probably removes the trailing newline unless the input is whitespace-only.
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