Skip to content

Commit 99ac076

Browse files
committed
Quote file paths used in bash scripts
1 parent 2eec010 commit 99ac076

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/util/GxfSorter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public File sortGff(File input, @Nullable File output) throws PipelineJobExcepti
5151
writer.println("#!/bin/bash");
5252
writer.println("set -x");
5353
writer.println("set -e");
54-
writer.println("GFF=" + input.getPath());
55-
writer.println("OUT_GFF=" + outputFile.getPath());
54+
writer.println("GFF='" + input.getPath() + "'");
55+
writer.println("OUT_GFF='" + outputFile.getPath() + "'");
5656

5757
String cat = inputIsGzip ? "zcat" : "cat";
5858
writer.println(cat + " $GFF | awk '{ if ($1 ~ \"^#\" ) print $0; else exit; }' > $OUT_GFF");
@@ -85,8 +85,8 @@ public File sortGtf(File input, @Nullable File output) throws PipelineJobExcepti
8585
writer.println("#!/bin/bash");
8686
writer.println("set -x");
8787
writer.println("set -e");
88-
writer.println("GTF=" + input.getPath());
89-
writer.println("OUT_GTF=" + outputFile.getPath());
88+
writer.println("GTF='" + input.getPath() + "'");
89+
writer.println("OUT_GTF='" + outputFile.getPath() + "'");
9090

9191
String cat = inputIsGzip ? "zcat" : "cat";
9292
writer.println(cat + " $GTF | awk '{ if ($1 ~ \"^#\" ) print $0; else exit; }' > $OUT_GTF");

SequenceAnalysis/src/org/labkey/sequenceanalysis/util/SequenceUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ else if (!samples.equals(header.getGenotypeSamples()))
503503
for (File vcf : files)
504504
{
505505
String cat = vcf.getName().toLowerCase().endsWith(".gz") ? "zcat" : "cat";
506-
bashCommands.add(cat + " " + vcf.getPath() + " | grep -v '^#';");
506+
bashCommands.add(cat + " '" + vcf.getPath() + "' | grep -v '^#';");
507507
}
508508

509509
try
@@ -523,7 +523,7 @@ else if (!samples.equals(header.getGenotypeSamples()))
523523
threads = Math.max(1, threads - 1);
524524
}
525525

526-
writer.write("} | bgzip -f" + (compressionLevel == null ? "" : " --compress-level 9") + (threads == null ? "" : " --threads " + threads) + " > " + outputGzip.getPath() + "\n");
526+
writer.write("} | bgzip -f" + (compressionLevel == null ? "" : " --compress-level 9") + (threads == null ? "" : " --threads " + threads) + " > '" + outputGzip.getPath() + "'\n");
527527
}
528528

529529
SimpleScriptWrapper wrapper = new SimpleScriptWrapper(log);
@@ -560,7 +560,7 @@ public static Set<String> getContigsInVcf(File vcf) throws PipelineJobException
560560
{
561561
writer.println("#!/bin/bash");
562562
String cat = vcf.getPath().toLowerCase().endsWith(".gz") ? "zcat" : "cat";
563-
writer.println(cat + " " + vcf.getPath() + " | grep -v '#' | awk ' { print $1 } ' | sort | uniq");
563+
writer.println(cat + " '" + vcf.getPath() + "' | grep -v '#' | awk ' { print $1 } ' | sort | uniq");
564564
}
565565

566566
SimpleScriptWrapper wrapper = new SimpleScriptWrapper(null);

0 commit comments

Comments
 (0)