From: Logan Capaldo Date: 2006-08-01T21:34:32+09:00 Subject: Re: Default shell for Kernel::system() ? On Aug 1, 2006, at 4:20 AM, Ronald Fischer wrote: > Ist it possible to kind of define a default shell which will be used > for Kernel::system? I often need to invoke from my Ruby scripts > external commands, involving redirection and globbing, for example > (bash syntax) > > foo [a-z]* 2>&- > bar << > etc. Since these syntactic elements are shell specific, I need to > specify the shell somehow, for example: > > system("bash --norc -c 'foo [a-z]* 2>&-'") > system("bash --norc -c 'bar << > which is a bit cumbersome. Of course one obvious solution would be > to define a new function: > > def bash(cmd) > system("bash --norc -c '"+cmd+"'") > end > > And use instead > > bash('foo [a-z]* 2>&-') > bash('bar << > But this solution has two drawbacks: > > First one has to pay special attention that the shell command > itself should no contain single quotes. For example, it is all too > tempting > to write a call > > bash("my_command 'one argument'") > > which looks correct at first sight, but will have a different > effect than > > bash('my_command "one argument"') > > due to the interference between Ruby- and bash quoting. > > Another drawback of this solution is that one has to include the > definition of the "bash" function with each Ruby script. > > So I wonder whether there is may be a simple, builtin solution > for this problem - say, a way to specify the "default shell" used > for system(). > > Ronald > > -- > Ronald Fischer > Posted via http://www.newsoffice.de/ > > I'm pretty sure the "default" shell for system is /bin/sh on a *nix.