-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(git-bulk): fix workspace selection when cd fails #1197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!- Surprised this wasn't already here.
As a side-note, those other eval
s are a bit suspicious to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we exit 1 when $rwsdir is expanded to ""?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Fixed in 145ecdd
. :)
Documentation has been added in |
@pierreay |
cd
may fails for multiple reasons:.gitconfig
manuallyCurrently, if
cd
fails, theBulkOp
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.