]> git.donarmstrong.com Git - uiuc_igb_scripts.git/blobdiff - dqsub
only escape if the command contains a space
[uiuc_igb_scripts.git] / dqsub
diff --git a/dqsub b/dqsub
index b1d1d0519e0e5b398e0c09ade09fe1491322b47f..1682d058c4871516720932a1a80f29ef2cd447ad 100755 (executable)
--- a/dqsub
+++ b/dqsub
@@ -150,7 +150,10 @@ if ($options{interactive} and @ARGV) {
 }
 
 # pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
-print STDERR join("\n",@USAGE_ERRORS) and exit 1 if @USAGE_ERRORS;
+if (@USAGE_ERRORS) {
+    print STDERR map {"$_\n"} @USAGE_ERRORS;
+    exit 1;
+}
 
 # OK. Generate the options to qsub which we'll be using
 my @qsub_options = generate_qsub_options(\%options,\@ARGV);
@@ -216,7 +219,9 @@ sub generate_qsub_options{
     if ($options->{name}) {
         push @qo,'-N',$options->{name};
     } else {
-        push @qo,'-N',join('_',@{$args}[0..min($#{$args},2)]);
+        push @qo,'-N',join('_',
+                           map {my $a = $_; $a =~ s/[^a-zA-Z0-9]*//g; $a;}
+                          @{$args}[0..min($#{$args},2)]);
     }
     # join error and output streams
     if ($options->{join}) {
@@ -255,7 +260,7 @@ sub write_qsub_script {
     my ($opt,$arg,$array) = @_;
 
     my $script = "#!/bin/bash\n";
-    my $command = join(' ',map {qq('$_')} @{$arg});
+    my $command = join(' ',map {$_ =~ /\s/?qq('$_'):$_} @{$arg});
         $script .= <<EOF;
 # this script was written by dqsub
 EOF