[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

system() doesn't work but %x does

Philip Mateescu

8/20/2007 10:02:00 PM


I'm trying to issue an "svn add" command from a script to add everything
under the current folder to subversion.
Command line works:
# svn add --force *

%x / backticks work
out = %x[svn add --force *]

system() does not.
system('svn', 'add', '--force', '*') produces "svn: warning: '*' not
found"

I suspect there is some subtlety in regard to the expansion of the "*";
is there any way of making it work with system()?

Thanks.
--
Posted via http://www.ruby-....

5 Answers

Jano Svitok

8/20/2007 10:19:00 PM

0

On 8/21/07, Philip Mateescu <philipmateescu+ruby-forums@gmail.com> wrote:
>
> I'm trying to issue an "svn add" command from a script to add everything
> under the current folder to subversion.
> Command line works:
> # svn add --force *
>
> %x / backticks work
> out = %x[svn add --force *]
>
> system() does not.
> system('svn', 'add', '--force', '*') produces "svn: warning: '*' not
> found"
>
> I suspect there is some subtlety in regard to the expansion of the "*";
> is there any way of making it work with system()?

I guess '*' is handled by the shell. `` invokes the command via shell,
while system does it directly (and you have to expand * yourself).

So, there are two possibilities:
1. invoke /bin/sh (or whatever shell are you using) with arguments to
call svn add...
2. expand it yourself (Dir.glob might be helpful)

NB: I'm curious: why do you insist on system()?

Nobuyoshi Nakada

8/20/2007 11:24:00 PM

0

Hi,

At Tue, 21 Aug 2007 07:18:49 +0900,
Jano Svitok wrote in [ruby-talk:265570]:
> > I'm trying to issue an "svn add" command from a script to add everything
> > under the current folder to subversion.
> > Command line works:
> > # svn add --force *
> >
> > %x / backticks work
> > out = %x[svn add --force *]
> >
> > system() does not.
> > system('svn', 'add', '--force', '*') produces "svn: warning: '*' not
> > found"
> >
> > I suspect there is some subtlety in regard to the expansion of the "*";
> > is there any way of making it work with system()?
>
> I guess '*' is handled by the shell. `` invokes the command via shell,
> while system does it directly (and you have to expand * yourself).

To be accurate, system with multiple arguments bypasses shell,
while backticks and system with single string contains shell
metacharacters invokes a shell.

> So, there are two possibilities:
> 1. invoke /bin/sh (or whatever shell are you using) with arguments to
> call svn add...
> 2. expand it yourself (Dir.glob might be helpful)

3. use single string argument.
system('svn add --force *')

--
Nobu Nakada

Philip Mateescu

8/20/2007 11:34:00 PM

0

Jano Svitok wrote:

> NB: I'm curious: why do you insist on system()?

I'm using i386-cygwin and system() seemed to be better behaved when some
of the tools I call are not cygwin based. (such as nant)
--
Posted via http://www.ruby-....

JustDoIt

11/13/2012 3:20:00 AM

0

"Obveeus" <Obveeus@aol.com> wrote in news:k7rtdr$2bl$1@dont-email.me:

>
> "David" <dimlan17@yahoo.com> wrote:
>> http://www.variety.com/article/VR1118062128?r...
>>
>> U.S. stations demand distrib fees in Canada
>> WDIV, KSTP, WIVB, WNLO, WHEC band together
>> By Brendan Kelly
>>
>> Five local U.S. stations have banded together to ask the Canadian
>> government to force Canuck cable and satellite players to pay for
>> distributing their signal north of the border.
>
> Its about time.

Why should anyone pay anything for entertainment that already has
commercial fees they charge?

Michael Black

11/13/2012 3:59:00 AM

0