braid icon indicating copy to clipboard operation
braid copied to clipboard

Spaces in command arguments break things

Open Devmeon opened this issue 4 years ago • 5 comments

Command line: braid add --verbose ssh://[email protected] Externe/project

Output:

Braid: Executing `git --version` in D:/folder
Braid: Executing `git rev-parse --is-inside-work-tree` in D:/folder
Braid: Executing `git rev-parse --show-prefix` in D:/folder
Braid: Executing `git status` in D:/folder
Braid: Executing `git rev-parse HEAD` in D:/folder
Braid: Executing `git add .braids.json` in D:/folder
Braid: Adding mirror of 'ssh://[email protected]'.
Braid: Executing `git --version` in D:/folder
Braid: Executing `git rev-parse --is-inside-work-tree` in D:/folder
Braid: Executing `git rev-parse --show-prefix` in D:/folder
Braid: Executing `git config remote.master/braid/Externe/project.url` in D:/folder
Braid: Setup: Creating remote for 'Externe/project'.
Braid: Executing `git remote add master/braid/Externe/project C:/Users/HeadQuarter n°1/.braid/cache/ssh___git_url.git` in D:/folder
Braid: Shell error: usage: git remote add [<options>] <name> <url>

braid version : braid 1.1.3 git version : git version 2.27.0.windows.1

Devmeon avatar Sep 23 '20 09:09 Devmeon

Without testing, it looks like the problem is that you have a space in your username and Braid joins command arguments with spaces and passes the result to the shell without any quoting. :frowning_face: Hopefully we can fix this by moving everything to the forms of Open3.capture3, etc. that take a list of arguments.

However, it's generally advisable (even on unix-like OSes) to avoid spaces in file paths for software development work because lots of less-used development tools have such bugs, although as they get more used, the bugs tend to get fixed (as is happening here with Braid). Indeed, in some programming environments such as makefiles, trying to defend against all characters treated specially by the shell entails so much clutter in the code that it's considered better to require users not to use those characters; maybe we should be moving off of those environments, but realistically we will be stuck with them for many years. In fact, I think the removal of spaces from a lot of default folder names in Windows Vista (e.g., Documents and Settings -> Users) was at least partly for this reason, though I haven't confirmed this.

mattmccutchen avatar Sep 23 '20 10:09 mattmccutchen

Your are right, the problem was the space in my username. After renaming my username, it went smooth as expected.

Devmeon avatar Sep 23 '20 12:09 Devmeon

I'm glad to have confirmation of what the problem was and that you worked around it. This is still a bug in Braid.

mattmccutchen avatar Sep 23 '20 12:09 mattmccutchen

I'll be glad to see this issue fixed. In my scenario, it was just one folder, that I had to rename and add an _ instead of space, but on some cases, there are several directories one inside the other where there are spaces in few of them. On existing projects, renaming a folder (In my case, the solution has over 110 projects), might break things.

Saragani avatar Jun 07 '22 13:06 Saragani

I'm working on getting the Braid::Operations::Git class statically typed, which is going to require extensive rework and review of that class and all calls to it anyway, and I'm hoping it will be efficient to fix the problems with spaces at the same time.

mattmccutchen avatar Jun 20 '22 01:06 mattmccutchen