Skip to content
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

Fix equality test in vagrant-tramp-ssh #26

Merged
merged 2 commits into from
Jan 21, 2016
Merged

Conversation

kotfic
Copy link
Contributor

@kotfic kotfic commented Dec 18, 2015

This should resolve issues where a Vagrantfile generates multiple named
boxes.

This should resolve issues where a Vagrantfile generates multiple named
boxes.
Prints the name $NF,  then subtracts the name from the last field from
the $NF variable,  then substitutes " " for the field seperator "_",
then prints the result.

I am not an awk expert (who is?),  but for my vagrant boxes with
underscores in the name this appears to work.
@kotfic
Copy link
Contributor Author

kotfic commented Dec 18, 2015

Also added (what i believe is) a fix for Issue #24

@kotfic
Copy link
Contributor Author

kotfic commented Jan 4, 2016

@dougm PTAL thanks!

@ryanprior
Copy link
Collaborator

Hi @kotfic, I don't understand it. Maybe you can help?

The new awk program is:
{print $NF; NF--; gsub(/ /, "_", $0); print $0}

We print the total number of fields, which will always be one or two. So first we print, say, "2."

Then we decrement the number of fields, substitute underscores for spaces, and print the result, say "test vm"

The first print becomes $name, and the second becomes $dir_name. So in our example, $name="2" and $dir_name="test vm"

That doesn't seem right to me. Do I misunderstand how that awk code works?

@kotfic
Copy link
Contributor Author

kotfic commented Jan 14, 2016

hi @ryanprior, print $NF actually prints the last field, not the number of fields (it is like running print $2 if there were only 2 fields), we then decrement the NF counter so the last field is not included, then join together all those fields with "_".

This means if you have a directory with underscores in the name (e.g. /path/to/some_folder) then the string passed to vagrant-tramp-ssh is some_folder_default and the tramp function tries to connect to folder_default which is incorrect. (note in the case of some_folder_default there are actually 3 fields).

@ryanprior
Copy link
Collaborator

@kotfic thank you for the explanation! The awk code I write tends to be very literal and that line went over my head. ;-D

I'm merging this change, even knowing that it may break somebody's configuration. I can't help but consider vagrant-tramp to be unstable until we land integration with vagrant machine-readable output and make a stable release.

See also: #8

ryanprior added a commit that referenced this pull request Jan 21, 2016
Fix equality test in vagrant-tramp-ssh, treat string after the last underscore as the machine name.
@ryanprior ryanprior merged commit 660b84f into dougm:master Jan 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants