Public bug reported:

I am using Ubuntu 9.10. Sorry, but I do not know the correct package
number.

Consider the following two bash scripts:

#!/bin/bash
while getopts "a:bc" flag; do
  echo "$flag   $OPTARG"
done

and

#!/bin/bash
while getopts "a:bc" flag "-a test -b -c"; do
  echo "$flag   $OPTARG"
done

Let the first be test1 and the second be test2.
Output from test1:
./test1 -a test -b -c
a       test
b       
c

Output from test2:
./test2
a        test -b -c

Please note that "-a test -b -c" command line in the second case is passed as a 
parameter to getopts.
I expected:
./test2
a       test
b       
c

So, it seems like getopts do not correctly parse arguments from a string
given as an argument rather than from a script command line.

** Affects: ubuntu
     Importance: Undecided
         Status: New


** Tags: bash

-- 
Bash script getopts strange behaviour
https://bugs.launchpad.net/bugs/522591
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to