pallassgj / bpipe

Automatically exported from code.google.com/p/bpipe
0 stars 1 forks source link

Impossible to pass an empty string parameter on the command line #93

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a file named test.groovy with this content:
MY_DB="some_file.txt"
convert_ids = {
   doc title: "Convert IDs",
       desc:  """Parameters:
                    'db', database to use (skip if db is '')""",
       constraints: "",
       author: ""
   println("db: "+db)
   if (db) {
      filter("convert_ids") {
         exec """
            echo "Converting IDs!"
         """
      }
   } else {
      exec """
         echo "Skipping ID conversion"
      """
      forward input
   }
}
Bpipe.run {
   convert_ids.using(db:MY_DB)
}

2. Create an input file: touch data.txt

3. Run bpipe: bpipe run -p MY_DB="" test.groovy data.txt

What is the expected output? What do you see instead?
I expect bpipe to report that $db is the empty string, i.e.:
db:
Instead, bpipe reports:
db: true
Setting a pipeline parameter to the empty string on the command line does not 
seem to work. In contrast, setting GCN_DB="" inside the Groovy file produced 
the expected output.

What version of the product are you using? On what operating system?
Bpipe 0.9.8.5
Linux x86_64

Please provide any additional information below.

Original issue reported on code.google.com by florent....@gmail.com on 18 Mar 2014 at 5:28

GoogleCodeExporter commented 9 years ago
Note the following inconsistency found using the .getClass() method:
   if set in the file, MY_DB="" is a Groovy String
   but when set on the command line with -p, MY_DB="" is a Groovy Boolean

I found a workaround that seems to be working. I just need to add
   db = db.toString() == "true" ? "" : db

...but the caveat is that it makes it impossible to set MT_DB to the string 
"true" now.

Original comment by florent....@gmail.com on 2 Jul 2014 at 5:39