Subversion Repositories DevTools

Rev

Rev 345 | Rev 4928 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 345 Rev 347
Line 399... Line 399...
399
 
399
 
400
#-------------------------------------------------------------------------------
400
#-------------------------------------------------------------------------------
401
# Function        : EscapeCommand
401
# Function        : EscapeCommand
402
#
402
#
403
# Description     : Escape input commands
403
# Description     : Escape input commands
-
 
404
#                   Can be called with two forms of arguments.
-
 
405
#                   If the there is only one item in the input list, then the
-
 
406
#                   command will be a single command that is to be processed
-
 
407
#                   by the shell. We cannot do escaping of space characters.
-
 
408
#
-
 
409
#                   If there is more than one item, then assume that each
-
 
410
#                   item will be a standalone command parameter - and we can
-
 
411
#                   quote spaces within the command stream.
-
 
412
#
404
#                   Must handle:
413
#                   Must handle:
405
#                       Embedded "
414
#                       Embedded "
406
#                       Embeded spaces
415
#                       Embeded spaces
407
#                   Doesn't (yet) handle embedded \
416
#                   Doesn't (yet) handle embedded \
408
#
417
#
Line 411... Line 420...
411
# Returns         : Return an escaped string
420
# Returns         : Return an escaped string
412
#
421
#
413
sub EscapeCommand
422
sub EscapeCommand
414
{
423
{
415
    my @cmd;
424
    my @cmd;
-
 
425
    my $arg_count = $#_;
416
 
426
 
417
    foreach ( @_ )
427
    foreach ( @_ )
418
    {
428
    {
419
        my $data = $_;
429
        my $data = $_;
420
        next unless ( $data );
430
        next unless ( $data );
421
        $data =~ s~"~\\"~g;
431
        $data =~ s~"~\\"~g;
422
        $data =~ s~ ~\\ ~g;
432
        $data =~ s~ ~\\ ~g if ($arg_count > 0);
423
        push @cmd, $data;
433
        push @cmd, $data;
424
    }
434
    }
425
    return join (' ', @cmd);
435
    return join (' ', @cmd);
426
}
436
}
427
 
437
 
428
 
-
 
429
    
-
 
430
1;
438
1;
431
 
439