Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell script evidence stopped working with 1.6.3 #443

Closed
eidermar opened this issue Feb 17, 2016 · 15 comments
Closed

Shell script evidence stopped working with 1.6.3 #443

eidermar opened this issue Feb 17, 2016 · 15 comments

Comments

@eidermar
Copy link

As reported by another user on the google groups the shell script evidence source seems to be broken with the recent update. My script was working perfectly until recent 1.6.3 update and stopped returning a positive result when true:

#!/bin/sh

for ip in 192.168.0.{30..32}; do ping -t 1 $ip > /dev/null && echo "${ip} is up"; done

Thanks for your support!

@dustinrue
Copy link
Owner

The evidence source hasn't changed in 11 months...can you try http://www.controlplaneapp.com/download/1.6.2 and see if it starts working again?

@eidermar
Copy link
Author

I tried. It's working in 1.6.1 but it's not working in either 1.6.2 or 1.6.3
For the moment I'm rolling back to 1.6.1 to keep it functional. Is there any risk with this version regarding sparkle framework?

@dustinrue
Copy link
Owner

Yes, 1.6.1 has the sparkle issue. 1.6.2+ are the only versions compiled on newer versions of Xcode so I'm guessing that's the issue.

@wallneradam
Copy link

I have the same issue. The scripts are called, but the results never interpreted as true.

@dustinrue
Copy link
Owner

I just pushed an update, try it and let me know if it's working better for you now.

@eidermar
Copy link
Author

Thank you for the update. Unfortunately still not working on my side. Script is called without an error but always returned as false.

@BashfulBits
Copy link

I'm seeing the same behavior (Shell script evidence sources work in 1.6.1, broken in 1.6.2, semi-functional in 1.6.4). In my case, the script in question that was working is run with the applescript interpreter:
#!/usr/bin/osascript

with an error or return line, which then returns 1 or 0 to the shell as verified with echo $? after calling the script.
1.6.1: Works (returns correct value in evidence sources based on script logic)
1.6.2: Broken (always shows as false in evidence sources)
1.6.4: Broken (always shows as false in evidence sources)

To test, I then created two bash scripts that return 0 or 1:
#!/bin/bash exit 0

#!/bin/bash exit 1

1.6.1: Works (first script returns true in evidence sources, second one is false)
1.6.2: Broken (both scripts always show false in evidence sources)
1.6.4: Works (first script returns true in evidence sources, second one is false)

@dustinrue
Copy link
Owner

1.6.2 simply doesn't work, this is confirmed. Apple clearly changed the behavior of NSTask but it isn't documented. Using echo $? won't work because...reasons with how NSTask is working. If you exit $? it might work however. As it is now, you can either echo 0 or 1 or exit with 0 or 1 to get the expected behavior. Using echo $? is going to fail.

@BashfulBits
Copy link

Thanks for the hint. Just in case others are running into issues with applescripts used as evidence sources, I was able to workaround this with the following (assuming shouldExit indicates whether the output of the script should fail):

1.6.1 and earlier, I could exit an applescript and have it interpreted as success or failure like this:

#!/usr/bin/osascript
if shouldExit = "fail" then
   error "Exiting with failure"
else
   return "Exiting with success"
end if

With 1.6.2+, I can workaround with the following change:

#!/usr/bin/osascript
if shouldExit = "fail" then
   log "Exiting with failure"  -- Not necessary, but useful for terminal output
   error "1"
else
   log "Exiting with success"  -- Not necessary, but useful for terminal output
   return "0"
end if

Is this something that should be filed with Apple?

@fnurl
Copy link

fnurl commented Apr 13, 2016

Thanks @dustinrue for the info and @ericpruett for the tip.

@dustinrue Perhaps the info in the interface could be changed to reflect the change in behavior.

@fnurl
Copy link

fnurl commented Apr 13, 2016

I also just noticed that exit 0 and exit 1 work with bash but not with zsh...

@noaho
Copy link

noaho commented Sep 2, 2017

I have the same problem. I can't get Shell scripts to execute either, they bomb out with (script terminated with a non-zero status '127').

I use zsh.

@dustinrue
Copy link
Owner

At the top of your script you adding #!/bin/zsh?

@noaho
Copy link

noaho commented Oct 3, 2017

Thanks @dustinrue, I tried this and now it works, but it seems like the path is not being loaded. Eg my command fails unless I run /usr/local/bin/vagrant, while if I run the script normally, vagrant by itself is enough.

@dustinrue
Copy link
Owner

I'm not surprised. I'm almost positive the scripts are run through bash specifically so your environment isn't going to be loaded when you ask bash to run zsh to run your script. What you can do is, after the #!/bin/zsh, is source your zsh environment files. source $HOME/.zshrc for example. I'm not completely familiar with zsh so your personal profile scripts might be named differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants