John
John

Reputation: 329

How do I escape a single slash on command line to Git bash?

When I do git work on Windows, I'm typically using Git bash and I'm having trouble passing in a simple slash to script:

$ bash --version
GNU bash, version 4.4.12(1)-release (i686-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ python --version
Python 2.7.14
$ cat ~/tmp/args
#! /usr/bin/env python

import sys
import json

print json.dumps(sys.argv, indent=2, sort_keys=True)
$ ~/tmp/args /
[
  "C:/Users/jpfuntne/tmp/args",
  "C:/Program Files (x86)/Git/"
]
$ ~/tmp/args \/
[
  "C:/Users/jpfuntne/tmp/args",
  "C:/Program Files (x86)/Git/"
]
$ ~/tmp/args '/'
[
  "C:/Users/jpfuntne/tmp/args",
  "C:/Program Files (x86)/Git/"
]
$

I can't figure out how to get the slash to not get replaced with C:/Program Files (x86)/Git/. I also use Cygwin bash (GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin)) for regular work on Windows and it doesn't have the same problem there. So I can work around it but it bugs me that I can't find a solution.

Upvotes: 2

Views: 1318

Answers (1)

John
John

Reputation: 329

$ ~/tmp/args //
[
  "C:/Users/jpfuntne/tmp/args",
  "/"
]

Upvotes: 1

Related Questions