brianp / muxed

Another TMUX project manager
MIT License
59 stars 3 forks source link

BUG: Cannot handle directories with spaces in it #11

Closed scottbrown closed 8 years ago

scottbrown commented 8 years ago

I know, it's bad form to have spaces in directory names. But when I used one of my existing tmuxinator configuration files that opens up a directory with spaces in it, muxed incorrectly parses only the first word instead of the entire string.

Config:

# ~/.tmuxinator/jps-ledger.yml

name: jps-ledger
root: ~/JustPlainSimple Technologies Inc./financials/ledgers
...

Output:

cd ~/JustPlainSimple Technologies Inc./financials/ledgers
git status
greenhole:Downloads scott$ cd ~/JustPlainSimple Technologies Inc./financials/ledgers
git status
-bash: cd: /Users/scott/JustPlainSimple: No such file or directory
greenhole:Downloads scott$ git status
fatal: Not a git repository (or any of the parent directories): .git
greenhole:Downloads scott$
brianp commented 8 years ago

Hey @scottbrown, Thanks for reporting this so thoroughly. I'll be able to create test cases for just this. My initial thought is it might be a bug in the yaml-parser I'm using. I'll do some investigation to find where the error lies and how it can be addressed.

Thanks for testing it out!

brianp commented 8 years ago

This is not the yaml parser at all. It's simple string quoting in the terminal. Currently it is sending the command as noted above: cd ~/JustPlainSimple Technologies Inc./financials/ledgers. We can fix this by quoting the directory we desire changing to as cd "~/JustPlainSimple Technologies Inc./financials/ledgers". I've written an integration spec that verified the bug, and the above fix for it.

Any thoughts on that as a fix, causing problems down the road for variants of possible root dirs?

scottbrown commented 8 years ago

There shouldn't be any problems with your fix, as the point of the root key is a directory, so the entire value can be wrapped in quotes. This will also help if/when you ship a Windows binary, as they use whitespace more often in directory names (e.g. Program Files). It won't break anything on POSIX systems either, as the way to deal with directories and filenames with whitespace (or other escape characters) is to wrap it in quotes (e.g. mv "/vol/This is a file.txt") and is considered best practice in Bash scripts.