Open hamann opened 11 years ago
I chose to return an exception for non-zero exit codes to avoid any ambiguity around successes and failures. Ideally Rye.shell would be consistent with that, but the class usage is kind of a special case in the sense that it's really only used as a replacement for backticks or Kernel.cmd
.
disable_safe_mode
only affects the whitelist and escaping (e.g. globs, tildas, etc). Would a disable_exceptions
method solve your problem?
Hi,
I hit this problem with the "ps" command when I wanted to see if a process existed or not and ps return -1 when it does not found the process, which in my case, I was expecting.
To handle that I had to add an exception handler.
I would prefer to get the same as under the shell, with no output in my case and the exit status set to -1 and no exception.
Don't know if this is possible under Rye.
Best regards René PENNARUN
On 03/29/2013 06:13 PM, Delano Mandelbaum wrote:
I chose to return an exception for non-zero exit codes to avoid any ambiguity around successes and failures. Ideally Rye.shell would be consistent with that, but the class usage is kind of a special case in the sense that it's really only used as a replacement for backticks or |Kernel.cmd|.
|disable_safe_mode| only affects the whitelist and escaping (e.g. globs, tildas, etc). Would a |disable_exceptions| method solve your problem?
— Reply to this email directly or view it on GitHub https://github.com/delano/rye/issues/31#issuecomment-15650538.
Yes, disabling exception based on command return codes would resolve it. Thanks!
What's about raising an exception when stderr isn't empty?
mixlib-shellout e.g. has a method 'error!' which does exactly that, raise an exception when stderr isn't empty, but that has to be called explicitly, bound to the command called before. I think such an approach makes more sense => let the user decide when an exit code <> 0 is really critical or an exception
:+1:
Is there a fix for that issue now ? I'm trying to delete an unexisting file and I want to handle exception by my self but the stderr is always printed in my shell. I would just like to hide it and display a custom error message in place of. A clue ?
@Hito01 You can pass the option :error => false
to Rye::Box.new
to avoid printing the STDERR
.
Well, I already tried this :
Rye::Box.new(host, safe: false, user: 'root', :error => false)
But the error is still displayed in my terminal.
$box.git "clone", "foo@git.bar.net:#{options[:g]} "
Here is the command that I try to execute. In fact the repository doesn't exist and so I get something like : Access denied. fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Where am I wrong ?
You can also try adding an exception hook for the Exception
class which does nothing but return.
See:
Hi,
I'm playing with rye and discovered that rye behaves differently when executing commands local or via ssh
Why does rye raise an exception when I want to check if a directory exists?