Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #7445
| From | August Werner <august-werner@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: ruby -e and global variables |
| Date | 2021-09-24 19:09 +0000 |
| Message-ID | <ir6m2jFbrmdU1@mid.individual.net> (permalink) |
| References | <43e02e5e-06a7-4a00-bcf8-69154b9c64fdn@googlegroups.com> |
tcb...@gmail.com wrote: > I'm trying to assign a global variable when using ruby -e > `ruby -e "$a=3"` > -e:1: syntax error, unexpected '=' > > So it seems I can't assign global variables when using ruby -e > What I wanted is to assign $stdout = StringIO.new > so I capture the output Hello, Your problem with ruby -e "$a=3" and therefore also with ruby -e "$stdout = StringIO.new". Regardless of whether this makes sense, you have a problem with the shell (or perhaps other command line interpreter). You are using an unprotected ruby command text with characters that the shell interprets for itself. With: ruby -e '$a=3' or ruby -e "\$a=3" no one complains anymore.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar
ruby -e and global variables "tcb...@gmail.com" <tcblues@gmail.com> - 2021-09-24 05:51 -0700 Re: ruby -e and global variables August Werner <august-werner@invalid.invalid> - 2021-09-24 19:09 +0000
csiph-web