Project

General

Profile

Feature #2351

Updated by nahi (Hiroshi Nakamura) over 13 years ago

=begin 
  
  I encountered this problem while using a feature of the very powerful zsh(ell). 
 
  In zsh one can use regular expressions in shell commands, like accessing files in  
  different locations with one command: 
 
  cat -la /mnt/server(1|2)/some/path/and/file_log 
 
  The default /bin/sh does not as it is a bash in most cases. 
 
  Example: 
   % irb     
   >> ENV['SHELL'] 
   => "/usr/bin/zsh" 
   >> system('cat /mnt/server(1|2|3)/file | sed, awk, etc.') 
   sh: Syntax error: "(" unexpected 
   => false 
 
  I can update the ENV['SHELL'] to every setting I'd like, but system() will always refer to /bin/sh.  
 
  Thus my script will always fail as long as I do not circumvent this feature with something like: 
 
  system('/usr/bin/zsh -c "cat /mnt/server(1|2|3)/file | sed, awk, etc."') 
 
  I tested this with different ruby versions installed by different Linux distributions: 
  ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] Ubuntu 9.04 
  ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux] openSuSE 11.1 
  ruby 1.8.7 (2009-04-08 patchlevel 160) [i386-freebsd7] 
  ruby 1.8.5 (2006-08-25) [i386-linux] CentOS release 5.3 (Final) 
 
 =end 
 

Back