Merge branch 'release/0.4.1'
diff --git a/AUTHORS b/AUTHORS
index 4b6bd0a..060f09f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,5 +10,6 @@
 - Nowell Strite
 - Felipe Talavera
 - Guillaume-Jean Herbiet
+- Joseph A. Levin
 
 Portions derived from other open source works are clearly marked.
diff --git a/Changes.mdown b/Changes.mdown
index fe62f34..72c04bc 100644
--- a/Changes.mdown
+++ b/Changes.mdown
@@ -1,3 +1,17 @@
+0.4.1:
+-----
+Release date: **2011/02/04**
+
+* New option `-d` added to `git flow init`, to initialize with defaults without
+  asking for input interactively.  Ideal for creating git-flow enabled repos in
+  custom scripts.
+
+* The parsing issues related to git-flow feature's flags are now dealt with on
+  all known platforms.  (Fixed #54, #62, #86, #97)
+
+* Escape queries for detecting branch/tag names.  (Fixed #91) 
+
+
 0.4:
 ---
 Release date: **2010/10/18**
diff --git a/README.mdown b/README.mdown
index ecaa11a..44c13fb 100644
--- a/README.mdown
+++ b/README.mdown
@@ -1,31 +1,80 @@
-git-flow
+git-flow ![Project status](http://stillmaintained.com/nvie/gitflow.png)
 ========
 A collection of Git extensions to provide high-level repository operations
 for Vincent Driessen's [branching model](http://nvie.com/git-model "original
 blog post").
 
 
+Getting started
+---------------
+For the best introduction to get started with `git flow`, please read Jeff
+Kreeftmeijer's blog post:
+
+[http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/](http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/)
+
+Or have a look at one of these screen casts:
+
+* [A short introduction to git-flow](http://vimeo.com/16018419) (by Mark Derricutt)
+* [On the path with git-flow](http://codesherpas.com/screencasts/on_the_path_gitflow.mov) (by Dave Bock)
+
+
 Installing git-flow
 -------------------
-The easiest way to install git-flow is using Rick Osborne's excellent
-git-flow installer, which can be run using the following command:
 
-	$ wget -q -O - http://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | sudo sh
+### Mac OS
+If you're on a Mac and use [homebrew](http://github.com/mxcl/homebrew), it's simple:
 
-For __OSX__ users, the `wget` command isn't available by default, but `curl` is, so you can run:
+    $ brew install git-flow
 
-	$ curl http://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | sudo sh
+If you're on a Mac and use [MacPorts](http://macports.org/), it's simple:
 
-For __Windows__ users who wish to use the automated install, it is suggested that you install [Cygwin](http://www.cygwin.com/)
-first to install tools like sh and wget. Then simply follow the command:
+    $ port install git-flow
 
-	c:\Users\<user> wget -q -O - http://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | sh
+### Linux, etc.
+Another easy way to install git-flow is using Rick Osborne's excellent git-flow
+installer, which can be run using the following command:
 
-If you prefer a manual installation, please use the following instructions.
-After downloading the sources from Github, also fetch the submodules:
+	$ wget --no-check-certificate -q -O - https://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | sudo sh
 
-	$ git submodule init
-	$ git submodule update
+### Windows
+#### Using Cygwin
+For Windows users who wish to use the automated install, it is suggested that you install [Cygwin](http://www.cygwin.com/)
+first to install tools like `git`, `util-linux` and `wget` (with those three being packages that can be selected
+during installation). Then simply run this command from a Cygwin shell:
+
+	$ wget -q -O - https://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | sh
+
+#### Using msysgit
+This is much like the manual installation below, but there are additional steps required to install some extra tools that
+are not distributed with [msysgit](http://code.google.com/p/msysgit/).
+
+Clone the git-flow sources from Github:
+
+	$ git clone --recursive git://github.com/nvie/gitflow.git
+
+Copy git-flow's relevant files to your msysgit installation directory:
+
+	$ mkdir /usr/local/bin
+	$ cp git-flow* gitflow* /usr/local/bin/
+	$ cp shFlags/src/shflags /usr/local/bin/gitflow-shFlags
+
+Next up we need to borrow a couple of binaries from [Cygwin](http://www.cygwin.com/). If you don't have Cygwin installed, please 
+install it including the `util-linux` package. Apart from `util-linux`'s dependencies, no other packages are required. When you
+finished installation, copy the following files using msysgit's _Git Bash_. We assume the Cygwin's default installation path in C:\cygwin.
+
+	$ cd /c/cygwin/
+	$ cp bin/getopt.exe /usr/local/bin/
+	$ cp bin/cyggcc_s-1.dll /usr/local/bin/
+	$ cp bin/cygiconv-2.dll /usr/local/bin/
+	$ cp bin/cygintl-8.dll /usr/local/bin/
+	$ cp bin/cygwin1.dll /usr/local/bin/
+
+After copying the files above, you can safely uninstall your Cygwin installation by deleting the C:\cygwin directory.
+
+### Manual installation
+If you prefer a manual installation, please use the following instructions:
+
+	$ git clone --recursive git://github.com/nvie/gitflow.git
 
 Then, you can install `git-flow`, using:
 
@@ -61,69 +110,8 @@
 
 FAQ
 ---
-* **Can I still do manual branches and merges when I use git-flow?**  
-  Of course you can. `git-flow` does not forbid you to keep using vanilla Git
-  commands!
-
-  So if you want to merge `master` into `develop` for whatever reason you want
-  to, you can safely do so without breaking `git-flow` compatibility.  Do you
-  want to manually merge a feature branch X into another feature branch Y?  Not
-  a problem.  As long as you do it conciously and realize what this means for
-  finishing those branches later on.
-
-* **Why does git-describe not work for me?**  
-  When finishing release and hotfix branches, that branch's HEAD is first
-  merged into `master` and then into `develop`.  It is not the resulting new
-  merge commit from `master` that is merged back into `develop`.  This means
-  that a linear path from the new `develop` branch to the new `master` commit
-  is not created.  Even worse, a linear path is created from the new `develop`
-  branch to the *previous* `master` commit.  Although unintended, this is
-  simply an effect of using the current branching rules.
-
-  When using `git-describe` in these cases, you can get very confusing and
-  misleading results, since `git-describe` scans the current commits linear
-  history for the most recent tag it finds, which will always be the *previous*
-  tag.
-
-  I will change this behaviour in the next version of the branching model
-  explicitly and I will include this behavioural change in the first version of
-  the Python rewrite.
-
-  For more references to this problem, see:
-
-  - Issue [#49](http://github.com/nvie/gitflow/issues/49)
-  - These
-  	[two](http://groups.google.com/group/gitflow-users/browse\_thread/thread/9920a7df3d1c4908/0bb18a0bf7275ad6#0bb18a0bf7275ad6)
-  	[discussions](http://groups.google.com/group/gitflow-users/browse\_thread/thread/19efac724bb6418a)
-	on the [git-flow-users](http://groups.google.com/group/gitflow-users)
-	mailinglist.
-
-* **I'm getting errors when I use flags with git-flow!**  
-  `git-flow` uses the [shFlags](http://code.google.com/p/shflags/) library to
-  provide platform independent flag parsing (using wichever low-level flag
-  parsing libraries like `getopt` or `getopts` are available).  However,
-  `shFlags` does not work too well on a few platforms that haven't been tested
-  originally.  This results in errors like this:
-
-      flags:WARN getopt: option invalide -- 'f' -- 'init' flags:FATAL unable to parse provided options with getopt
-
-  The platforms that suffer these errors include:
-
-  - Gentoo
-  - Ubuntu
-  - Redhat Enterprise Linux
-
-  There are open issues related to this:
-  [#28](http://github.com/nvie/gitflow/issues/28) and
-  [#39](http://github.com/nvie/gitflow/issues/39). Unfortunately, there is no
-  simple fix for it and all hope is placed on the Python rewrite of `git-flow`,
-  see issue [#33](http://github.com/nvie/gitflow/issues/33).
-
-* **Can I use it with Windows?**  
-  There have been reports of Windows users using `git-flow`.
-  <del>Un</del>fortunately, I have no Windows environment to test it on, but
-  this [issue](http://github.com/nvie/gitflow/issues/issue/25) should be
-  helpful in setting it up.
+See the [FAQ](http://github.com/nvie/gitflow/wiki/FAQ) section of the project
+Wiki.
 
 
 Please help out
@@ -149,14 +137,6 @@
 in a Github fork, of course.
 
 
-Typical usage:
---------------
-For the best introduction to get started to `git flow`, please read Jeff
-Kreeftmeijer's blog post:
-
-[http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/](http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/)
-
-
 ### Initialization
 
 To initialize a new repo with the basic branch structure, use:
diff --git a/git-flow-feature b/git-flow-feature
index 8893598..226730a 100644
--- a/git-flow-feature
+++ b/git-flow-feature
@@ -170,22 +170,20 @@
 	fi
 }
 
-parse_cmdline() {
+parse_args() {
 	# parse options
 	FLAGS "$@" || exit $?
 	eval set -- "${FLAGS_ARGV}"
-}
-
-parse_args() {
-	parse_cmdline "$@"
 
 	# read arguments into global variables
-	NAME=$(last_arg "$@")
+	NAME=$1
 	BRANCH=$PREFIX$NAME
 }
 
 parse_remote_name() {
-	parse_cmdline "$@"
+	# parse options
+	FLAGS "$@" || exit $?
+	eval set -- "${FLAGS_ARGV}"
 
 	# read arguments into global variables
 	REMOTE=$1
diff --git a/git-flow-hotfix b/git-flow-hotfix
index a675619..5660131 100644
--- a/git-flow-hotfix
+++ b/git-flow-hotfix
@@ -65,7 +65,7 @@
                 warn ""
                 warn "You can start a new hotfix branch:"
                 warn ""
-                warn "    git flow hotfix start <name> [<base>]"
+                warn "    git flow hotfix start <version> [<base>]"
                 warn ""
 		exit 0
 	fi
@@ -124,7 +124,7 @@
 	eval set -- "${FLAGS_ARGV}"
 
 	# read arguments into global variables
-	VERSION=$(last_arg "$@")
+	VERSION=$1
 	BRANCH=$PREFIX$VERSION
 }
 
diff --git a/git-flow-init b/git-flow-init
index 461ee8c..57ab244 100644
--- a/git-flow-init
+++ b/git-flow-init
@@ -37,7 +37,7 @@
 #
 
 usage() {
-	echo "usage: git flow init [-f]"
+	echo "usage: git flow init [-fd]"
 }
 
 parse_args() {
@@ -49,8 +49,9 @@
 # Default entry when no SUBACTION is given
 cmd_default() {
 	DEFINE_boolean force false 'force setting of gitflow branches, even if already configured' f
+	DEFINE_boolean defaults false 'use default branch naming conventions' d
 	parse_args "$@"
-
+	
 	if ! git rev-parse --git-dir >/dev/null 2>&1; then
 		git init
 	else
@@ -68,6 +69,10 @@
 	local branch_count
 	local answer
 
+    if flag defaults; then
+        warn "Using default branch names."
+    fi
+
 	# add a master branch if no such branch exists yet
 	local master_branch
 	if gitflow_has_master_configured && ! flag force; then
@@ -101,9 +106,13 @@
 				fi
 			done
 		fi
-
+		
 		printf "Branch name for production releases: [$default_suggestion] "
-		read answer
+		if noflag defaults; then
+			read answer
+		else
+			printf "\n"
+		fi
 		master_branch=${answer:-$default_suggestion}
 
 		# check existence in case of an already existing repo
@@ -146,7 +155,11 @@
 		fi
 
 		printf "Branch name for \"next release\" development: [$default_suggestion] "
-		read answer
+		if noflag defaults; then
+			read answer
+		else
+			printf "\n"
+		fi
 		develop_branch=${answer:-$default_suggestion}
 
 		if [ "$master_branch" = "$develop_branch" ]; then
@@ -216,7 +229,11 @@
 	if ! git config --get gitflow.prefix.feature >/dev/null 2>&1 || flag force; then
 		default_suggestion=$(git config --get gitflow.prefix.feature || echo feature/)
 		printf "Feature branches? [$default_suggestion] "
-		read answer
+		if noflag defaults; then
+			read answer
+		else
+			printf "\n"
+		fi
 		[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
 		git config gitflow.prefix.feature "$prefix"
 	fi
@@ -225,7 +242,11 @@
 	if ! git config --get gitflow.prefix.release >/dev/null 2>&1 || flag force; then
 		default_suggestion=$(git config --get gitflow.prefix.release || echo release/)
 		printf "Release branches? [$default_suggestion] "
-		read answer
+		if noflag defaults; then
+			read answer
+		else
+			printf "\n"
+		fi
 		[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
 		git config gitflow.prefix.release "$prefix"
 	fi
@@ -235,7 +256,11 @@
 	if ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 || flag force; then
 		default_suggestion=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
 		printf "Hotfix branches? [$default_suggestion] "
-		read answer
+		if noflag defaults; then
+			read answer
+		else
+			printf "\n"
+		fi
 		[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
 		git config gitflow.prefix.hotfix "$prefix"
 	fi
@@ -245,7 +270,11 @@
 	if ! git config --get gitflow.prefix.support >/dev/null 2>&1 || flag force; then
 		default_suggestion=$(git config --get gitflow.prefix.support || echo support/)
 		printf "Support branches? [$default_suggestion] "
-		read answer
+		if noflag defaults; then
+			read answer
+		else
+			printf "\n"
+		fi
 		[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
 		git config gitflow.prefix.support "$prefix"
 	fi
@@ -255,7 +284,11 @@
 	if ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1 || flag force; then
 		default_suggestion=$(git config --get gitflow.prefix.versiontag || echo "")
 		printf "Version tag prefix? [$default_suggestion] "
-		read answer
+		if noflag defaults; then
+			read answer
+		else
+			printf "\n"
+		fi
 		[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
 		git config gitflow.prefix.versiontag "$prefix"
 	fi
diff --git a/git-flow-release b/git-flow-release
index aea6e42..05815bc 100644
--- a/git-flow-release
+++ b/git-flow-release
@@ -121,7 +121,7 @@
 	eval set -- "${FLAGS_ARGV}"
 
 	# read arguments into global variables
-	VERSION=$(last_arg "$@")
+	VERSION=$1
 	BRANCH=$PREFIX$VERSION
 }
 
diff --git a/git-flow-version b/git-flow-version
index cc8fd27..51fd671 100644
--- a/git-flow-version
+++ b/git-flow-version
@@ -36,7 +36,7 @@
 # policies, either expressed or implied, of Vincent Driessen.
 #
 
-GITFLOW_VERSION=0.4
+GITFLOW_VERSION=0.4.1
 
 usage() {
 	echo "usage: git flow version"
diff --git a/gitflow-common b/gitflow-common
index e5ffc74..75eb210 100644
--- a/gitflow-common
+++ b/gitflow-common
@@ -44,18 +44,14 @@
 warn() { echo "$@" >&2; }
 die() { warn "$@"; exit 1; }
 
-# argument processing
-last_arg() {
-    if [ $# -ne 0 ]; then
-        shift $(expr $# - 1)
-        echo "$1"
-    fi
+escape() {
+	echo "$1" | sed 's/\([\.\+\$\*]\)/\\\1/g'
 }
 
 # set logic
 has() {
 	local item=$1; shift
-	echo " $@ " | grep -q " $item "
+	echo " $@ " | grep -q " $(escape $item) "
 }
 
 # basic math
@@ -148,7 +144,7 @@
 git_is_branch_merged_into() {
 	local subject=$1
 	local base=$2
-	local all_merges=$(git branch --no-color --contains $subject | sed 's/^[* ] //')
+	local all_merges="$(git branch --no-color --contains $subject | sed 's/^[* ] //')"
 	has $base $all_merges
 }
 
@@ -219,7 +215,7 @@
 		return 0
 	fi
 
-	matches=$(echo "$(git_local_branches)" | grep "^$prefix$name")
+	matches=$(echo "$(git_local_branches)" | grep "^$(escape "$prefix$name")")
 	num_matches=$(echo "$matches" | wc -l)
 	if [ -z "$matches" ]; then
 		# no prefix match, so take it literally