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

Allow variable names to include dashes or spaces #60

Closed
denisidoro opened this issue Sep 24, 2019 · 5 comments · Fixed by #97
Closed

Allow variable names to include dashes or spaces #60

denisidoro opened this issue Sep 24, 2019 · 5 comments · Fixed by #97
Labels
new feature New feature or request

Comments

@denisidoro
Copy link
Owner

It's not evident that variables should only contain alphanumeric characters and underscores.

Using spaces and dashes would make variable references in scripts non trivial, though (eg "image name" would become "image_name").

@denisidoro denisidoro added the new feature New feature or request label Sep 24, 2019
@engrravijain
Copy link
Contributor

Hey @denisidoro, I would like to pick this issue up. Need some more clarification here what is the requirement exactly.

@denisidoro
Copy link
Owner Author

denisidoro commented Sep 27, 2019

Thanks, @engrravijain!

These should be valid arguments: foo, foo_bar, foo-bar and foo bar.

Today, only the first two are considered valid.

First, you need to change this regex: https://github.com/denisidoro/navi/blob/master/src/arg.sh#L3.

Then, when assigning values, you need to replace spaces and dashes by underscores here, because foo-bar isn't a valid bash variable: https://github.com/denisidoro/navi/blob/master/src/main.sh#L41

@denisidoro
Copy link
Owner Author

denisidoro commented Sep 27, 2019

Or another solution is to replace the dashes and spaces when reading the files. This way no other code would be modified. However, it would make the startup a little bit slower

@denisidoro
Copy link
Owner Author

Ah, don't forget to start from the dev branch instead of master

@engrravijain
Copy link
Contributor

Got it. Thanks, Denisidoro.

engrravijain added a commit to engrravijain/navi that referenced this issue Sep 28, 2019
engrravijain added a commit to engrravijain/navi that referenced this issue Sep 28, 2019
denisidoro added a commit that referenced this issue Sep 29, 2019
#60 names can include dashes or spaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants