Support working paths with spaces#9
Conversation
Added a new function for parsing out the working path from the tree strings that are output by 'git worktree list'. Used the new function to set the working directory instead of relying on positional parameters set by 'git worktree list'. Configured 'awk' calls to use tabs instead of spaces as field separators for a line. Distinguished the console message that is printed when switching to the main worktree.
|
@Koolstr thank you for the PR. We can modify the last command to use regex with git worktree list --porcelain | awk '$1=="worktree" {print}' Or with similar strategy, we can use |
Reworked and simplified the approach used for parsing out the working directory from 'git worktree list, by taking advantage of the '--porcelain' flag and using awk to directly identify the first line with the worktree & parse out the path from it. Removed now-unused function and its calls for parsing out the path via the previous array-based method.
|
I like that idea, it's certainly more clean and efficient. However, what you've suggested doesn't work when you have more than one worktree. In such a case, it will print/return multiple retrieved 'worktree' lines. Having For parsing the path without I've adapted the implementation according to your suggestion, removing the now unnecessary function related to my old approach. It seems to work as expected. Please review the updated approach. |
|
@Koolstr Thanks looks neat! 🚀 |

Resolves this issue.
Changes:
This can possibly be programmed more elegantly, so feel free to make improvements or suggestions if you have any.