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

Add escape sequences and test #1701

Merged
merged 1 commit into from
Jan 17, 2018
Merged

Add escape sequences and test #1701

merged 1 commit into from
Jan 17, 2018

Conversation

ihmels
Copy link
Contributor

@ihmels ihmels commented Jan 7, 2018

I think, the backslashes are not needed.

@ljharb
Copy link
Member

ljharb commented Jan 7, 2018

They are in fact needed; see #1322 (comment), #1279, and #1278.

@ljharb
Copy link
Member

ljharb commented Jan 7, 2018

We should add a regression test that aliases ., so that these tests would have failed. Want to update this PR to do that instead?

@ihmels
Copy link
Contributor Author

ihmels commented Jan 8, 2018

I updated my pull request to only remove the backslashes in README. I also added a test, in which an alias for . is set, but unfortunately it was not executed on Travis.


alias .='cat'

\. ../../nvm.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the \. here will make the alias not do anything; we don't need to test . vs \., what we need to test is the install script (not sourcing).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I have to define the alias in all files under test/install_script/, so that install.sh would always fail, if . is not escaped?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessarily in all files, a single test would be better.

README.md Outdated
@@ -135,8 +135,8 @@ Now add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to hav

```sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People will copy-paste this code; it's important it retains the \.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there are lines in the README, where no \ has been placed (see section “Install script”). These lines have to be modified, too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that's an oversight then. anything in a code block should have the \.

@ihmels
Copy link
Contributor Author

ihmels commented Jan 13, 2018

I’ve updated my pull request. Do I need to add the test file to something? The new test is not executed on Travis.

@ihmels ihmels changed the title Remove unnecessary escape sequences Add escape sequences and test Jan 13, 2018
@ljharb
Copy link
Member

ljharb commented Jan 13, 2018

Yes, you'll need to git add it, and also chmod a+x it :-) (also, maybe use "dot" instead of "." in the filename, just in case)

@ihmels
Copy link
Contributor Author

ihmels commented Jan 14, 2018

I made the test executable and fixed another bug that caused the alias not to be expanded.

alias .='cat'
NVM_ENV=testing \. ../../install.sh
\. ../../install.sh > /dev/null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the NVM_ENV=testing is still required tho; otherwise it will actually invoke the install script.

Copy link
Contributor Author

@ihmels ihmels Jan 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But when I set NVM_ENV=testing, nvm_do_install will not be executed, so I can’t test the sourcing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can test the sourcing without executing that function; for example, type nvm_do_install will only exit zero if it was sourced correctly.

Copy link
Contributor Author

@ihmels ihmels Jan 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to test line 368 in install.sh. type nvm_do_install is not enough or am I wrong?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, true. but in that case, you can invoke nvm_do_install manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm done.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this LGTM!

@ljharb ljharb added testing Stuff related to testing nvm itself. informational labels Jan 17, 2018
@ljharb ljharb merged commit 7ca8acc into nvm-sh:master Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
informational testing Stuff related to testing nvm itself.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants