[Bug 522591] Re: Bash script getopts strange behaviour

2011-06-01 Thread Ralph Corderoy
This is correct behaviour. Perhaps these two examples will make it more clear. $ OPTIND=1 $ while getopts :a:bc f -a foo -b -c bar; do > echo "f=$f arg='$OPTARG'" > done f=a arg='foo' f=b arg='' f=c arg='' $ $ OPTIND=1 $ while getopts :a:bc f '-a foo -b

[Bug 522591] Re: Bash script getopts strange behaviour

2010-02-17 Thread PeggySue
I have slept on this and I think bash is working correctly. If you put "-a test -b -c" all inside quotes it will be treated as a single flag/argument. Leave out the quotes and it will treat it as separate arguments. So below "-a test -b -c" is one argument; -b and -c are the second and third

[Bug 522591] Re: Bash script getopts strange behaviour

2010-02-16 Thread Gabe Gorelick
getopts is a bash builtin. ** Package changed: ubuntu => bash (Ubuntu) -- 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-b

[Bug 522591] Re: Bash script getopts strange behaviour

2010-02-16 Thread PeggySue
I get the same response on Ubuntu and Gentoo. I am not a bash expert but would make the observation that (note multiple quotes): #!/bin/bash while getopts "a:bc" flag '-a test' '-b' '-c'; do echo "$flag $OPTARG" done in test2 will generate: pe...@vostro ~/Desktop $ ./test2.sh a test b c a