From: Akinori MUSHA Date: 2009-11-10T01:10:02+09:00 Subject: [ruby-core:26655] Re: [Bug #2351] system() hardlinked to /bin/sh --pgp-sign-Multipart_Tue_Nov_10_01:09:24_2009-1 Content-Type: text/plain; charset=US-ASCII At Mon, 9 Nov 2009 23:41:29 +0900, Marcus Franke wrote: > 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 /bin/sh is hardcoded in system() because it is the only shell on Unix-like systems you can rely on, and it is a good thing to fix the shell in terms of writing a portable program. For example, sh and csh are so different you don't even have a common way to redirect stderr output. > Example: > % irb > >> ENV['SHELL'] > => "/usr/bin/zsh" > >> system('cat /mnt/server(1|2|3)/file | sed, awk, etc.') > sh: Syntax error: "(" unexpected > => false If you need to run a command-line that relies on a specific shell, you can and should specify it. system('/bin/zsh', '-c', 'cat /mnt/server(1|2|3)/file | sed, awk, etc.'); Or if you mean you want to run a command-line with the user's shell: system(ENV['SHELL'], '-c', command_line); I think the problem here is a documentation flaw. The desciption of system() should explicitly say that the method will call the standard shell of the running system, which is /bin/sh on Unix family systems (including Cygwin) and cmd.exe on Windows family systems. -- Akinori MUSHA / http://akinori.org/ --pgp-sign-Multipart_Tue_Nov_10_01:09:24_2009-1 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEABECAAYFAkr4PrQACgkQkgvvx5/Z4e5wpgCbBbrGPtbdWn+QM+cEs/+M5XZK 0JcAoMTgJMq6E7ymekSJwwkEOgsh/95R =2ZB4 -----END PGP SIGNATURE----- --pgp-sign-Multipart_Tue_Nov_10_01:09:24_2009-1--