fix(git-bulk): fix workspace selection when cd fails#1197
fix(git-bulk): fix workspace selection when cd fails#1197spacewander merged 9 commits intotj:mainfrom
Conversation
`cd` may fails for multiple reasons: - mistake when editing `.gitconfig` manually - previously existing workspace that have been removed - ... Currently, if `cd` fails, the `BulkOp` continue its execution ... in the workspace defined in a higher directory that where the user, despite the user specified a specific workspace (`-w`). The user should be noticed of a failed `cd` (this is really not expected for a valid configuration) and the operations should stop to not execute something unexpected.
spacewander
left a comment
There was a problem hiding this comment.
Maybe we can also drop the cd in this PR?
Get rid of poor `eval` syntax because they are vulnerable to command
injection, which may have unexpected side effects.
However, they enabled a useful feature: using environment variable
(*e.g.*, defined in a `.bashrc`) inside the `.gitconfig` to use dynamic
paths as `bulk` workspaces.
As such, I keep this feature possible by using the Bash's ${!VAR}
syntax, which allows to get the value of one variable using the name of
a another variable. However, arbitrary command injection is not possible
anymore.
I was surprised too, maybe not too many people invested time into |
Which one? There is 3 of them ^^'. We cannot get rid of the 2nd one without changing |
Sorry for my typo! Actually, I want to drop the |
spacewander
left a comment
There was a problem hiding this comment.
Should we doc the variable name feature added in this PR?
bin/git-bulk
Outdated
| if [[ ${rwsdir:0:1} == '$' ]]; then | ||
| # Dereference the `rwsdir` value which is a variable name. | ||
| rwsdir=${rwsdir:1} | ||
| rwsdir=${!rwsdir} |
There was a problem hiding this comment.
Should we exit 1 when $rwsdir is expanded to ""?
There was a problem hiding this comment.
You're right! Fixed in 145ecdd. :)
Documentation has been added in |
|
@pierreay |
cdmay fails for multiple reasons:.gitconfigmanuallyCurrently, if
cdfails, theBulkOpcontinue its execution ... in the workspace defined in a higher directory that where the user, despite the user specified a specific workspace (-w).The user should be noticed of a failed
cd(this is really not expected for a valid configuration) and the operations should stop to not execute something unexpected.