Space between single quote in Windows shell

250 views
Skip to first unread message

Andrzej Borucki

unread,
Apr 24, 2013, 2:11:17 PM4/24/13
to msy...@googlegroups.com
If I type:
git commit -a -m 'initial commit'
instead of
git commit -a -m "initial commit"'
will be warning:
fatal: Paths with -a does not make sense.
whereas in Linux shell is probably acceptable single quote.
This error occurred when I created repository at SourceForge - there is step by step described repository creation but with single quote
see: http://stackoverflow.com/questions/11914919/git-fatal-error-path-with-a-does-not-make-sense

Konstantin Khomoutov

unread,
Apr 24, 2013, 3:02:16 PM4/24/13
to Andrzej Borucki, msy...@googlegroups.com
On Wed, 24 Apr 2013 11:11:17 -0700 (PDT)
Andrzej Borucki <borucki...@gmail.com> wrote:

> If I type:
> git commit -a -m 'initial commit'
> instead of
> git commit -a -m "initial commit"'
> will be warning:
> fatal: Paths with -a does not make sense.
> whereas in Linux shell is probably acceptable single quote.

My take on this follows.
There are two facts:

1) POSIX shells (those found on Unix systems, Linux- or *BSD-based
systems, and on Mac OS) perform the so-called "argument expansion"
before calling the user-supplied command.
They also support quoting of arguments using both single quotes
and double quotes (these types of quoting have different semantics
but this is irrelevant to the issue in hand).

This means when you run
git commit -a -m 'Initial commit'
or
git commit -a -m "Initial commit"
in a POSIX shell, the program named "git" will be run with *four*
*distinct* arguments: "commit", "-a", "-m" and "Initial commit",
without the quotes.

The same behaviour is implemented in Git bash which is a Windows port
of the bash shell.

2) Windows shells do not perform argument expansion. Instead, they try
to parse out the command and as soon as this succeeds, they call that
command and pass the rest of the command line to it as a single
string. Splitting it up to single arguments hence becomes the task
of the program itself.

Leaving aside discussing of the ways such a splitting might be done,
it suffuces to say that most sensible programs try to follow the
established Windows shell conventions, so, for instance, they won't
typically take a single quote to mean a grouping character.

In the end, I reckon that when the Git binary sees the string
commit -a -m 'Initial commit'
passed to it, it parses out *five* arguments from it: "commit", "-a",
"-m", "'Initial" and "commit'", without the quotes.
Hence your commit message becomes "'Initial" and "commit'" is treated
as a pathname, which conflicts with "-a".

So in the end the rule to follow is simple: if you're following a
tutorial on Git which assumes the presence of a POSIX shell, either use
Git bash or convert what you're reading to the Windows shell semantics.

> This error occurred when I created repository at SourceForge - there
> is step by step described repository creation but with single quote
> see:
> http://stackoverflow.com/questions/11914919/git-fatal-error-path-with-a-does-not-make-sense

It's not clear what point you were trying to make indeed.
So I made a guess and tried to explain why the behaviour differ between
different shells. If this is not what you tried to ask about feel free
to reformulate your question.

Johannes Sixt

unread,
Apr 24, 2013, 3:30:36 PM4/24/13
to Andrzej Borucki, msy...@googlegroups.com
When you are on Windows CMD, don't use single-quotes; they are in no way
special. Use double-quotes.

-- Hannes

Andrzej Borucki

unread,
Apr 25, 2013, 3:14:22 AM4/25/13
to msy...@googlegroups.com, Andrzej Borucki
W dniu środa, 24 kwietnia 2013 21:30:36 UTC+2 użytkownik Johannes Sixt napisał:
When you are on Windows CMD, don't use single-quotes; they are in no way
special. Use double-quotes.

-- Hannes

It will be well if on Windows git give warning about single-quotes instead "Paths with -a does not make sense." especially for beginner user.


Konstantin Khomoutov

unread,
Apr 25, 2013, 5:15:25 AM4/25/13
to Andrzej Borucki, msy...@googlegroups.com
On Thu, 25 Apr 2013 00:14:22 -0700 (PDT)
Andrzej Borucki <borucki...@gmail.com> wrote:

> > When you are on Windows CMD, don't use single-quotes; they are in
> > no way special. Use double-quotes.
> It will be well if on Windows git give warning about single-quotes
> instead "Paths with -a does not make sense." especially for beginner
> user.

Git has nothing to do with single quotes, really.
Please work through my response to your original message to this thread
to understand why.

Understanding how quoting in a particular shell/OS/platform works is in
the hands of the user. If you don't want to invest your time and effort
to learn about this stuff, consider using one of GUI front-ends like
Git Extensions or TortoiseGit or SmartGit etc.
Reply all
Reply to author
Forward
0 new messages