If bash is in your path you can do
system(“bash -c “java -version””)
else you just have to put the full path, this works even on Windows
Of course that is not exactly what you want, you would like to tell
Kernel or whatever other object that wants to hear that kind of
message: “You are going to use /bin/bash for system from now on”.
So I went digging the code, no such luck, I just could not find the
definition of Kernel#system
neither with rb_define_method.system
nor with def\ssystem
and even less with
alias\s*system
or
rb_alias.*system
Hope that somebody more learned will help us out here.
alias\s*system
or
rb_alias.*system
Hope that somebody more learned will help us out here.
_ Ruby uses the underlying C exec call and any system that does
not use /bin/sh is severely broken. It’s part of the POSIX
standard. If you want bash, then use the multi-arg form of the
command which bypasses shell interpretation entirely.
Does anyone know if it is possible to use bash instead of sh as the
default shell when “system” is executed?
Whenever ‘system’ is executed? Not sure about that. But what you
might be able to do is have a new file that stores code which defines
‘system2’, and you could include that. It might be something like:
def system2(command)
system ‘bash’
system '#{command}
end
Of course, i have no clue (yet) how to use #{stuff} in my code, so
any help would automatically be worthy of worship.
Oh, and same with having two parameters in ‘do’ commands. Help? Please?
HTH
-------------------------------------------------------|
~ Ari
crap my sig won’t fit
Standards like the Single Unix Specification (and the LSB, and so on)
should be used as reasons for standardized behavior in a distributed
OS, but they aren’t really relevant to customized installs. If an end
user wants to configure a system differently from the standard, that’s
his/her business.
Does anyone know if it is possible to use bash instead of sh as the
default shell when “system” is executed?
For example, system(“java --version”) is executing java --version in sh,
instead of bash, which can be a problem when I tried to do error
redirection.
–
Others have indicated how you can execute the command with bash rather
than sh.
However, I’m interested in why you have problems with redirecting
standard
error with sh bat not bash. While I seem to remember bash offers some
additional functionality, I thought redirecting of stdin/stdout/stderr
was
pretty similar, if not in syntax at least in functionality. Also, its
been some
time since I did java, but from memory, it uses quite a few shell
wrapper
scripts and they are all in sh rather than bash.
Does anyone know if it is possible to use bash instead of sh as the
default shell when “system” is executed?
System() should always call /bin/sh (on a POSIX compliant system),
Where did you get that information from?
This behavior with respect to the Single Unix
Specification is documented at: