Nobuyoshi Nakada
8/20/2007 11:24:00 PM
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