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

Set token to empty value #24

Closed
pascalberger opened this issue Apr 5, 2016 · 12 comments
Closed

Set token to empty value #24

pascalberger opened this issue Apr 5, 2016 · 12 comments
Labels

Comments

@pascalberger
Copy link
Contributor

Currently it seems to not be possible to set the value of a token in the tokenizer task to an empty value. If I have a file containing the token __foo__ and a variable with no value set, the token is not replaced (Test-Path env:$matchedItem returns false).

It would be nice if the Tokenizer would also support to replace tokens with empty strings.

@pascalberger
Copy link
Contributor Author

@anangaur Any idea about this?

@harshil93 harshil93 added the bug label Apr 16, 2016
@harshil93
Copy link
Member

@pascalberger Yes this is a bug. I will try to fix it asap.

@harshil93
Copy link
Member

harshil93 commented Apr 16, 2016

I tried setting an environment variable in powershell with empty value and it doesn't set that variable.
[Environment]::SetEnvironmentVariable("TestVariable", "", "User") (This doesn't set the env variable)

I think an env variable with empty value means you are unsetting that environment variable and thus it is no longer passes the test-path env:$matchedItem check.

@pascalberger
Copy link
Contributor Author

@harshil93 Yes this was also my observation. Any approach how this should be solved? Would setting an empty value in case neither environment variable was set nor value was found in configuration be an option?

@pascalberger
Copy link
Contributor Author

@harshil93 @anangaur Any opinion about this?

@MarcelMichau
Copy link

I agree with @pascalberger. If an environment variable is unset (i.e. not found in configuration) by means of assigning it to an empty string, then the replaced variable should default to an empty string. i.e in the very last else block of the tokenise.ps1 script:
Write-Host "No value found for token '$match' - setting to empty string"
$variableValue = [string]::Empty
works fine for me at the moment.

pascalberger pushed a commit to pascalberger/Extension-UtilitiesPack that referenced this issue Jul 17, 2016
@pascalberger
Copy link
Contributor Author

I've created a PR for this: #48. @harshil93 @anangaur Any chance to get this merged and released?

@harshil93
Copy link
Member

@pascalberger - One issue I can see with setting a not defined variable to an empty is breaking existing behavior if someone later in their tasks is doing something with unassigned variables.

Given this, I think an optional checkbox option telling user to replace undefined with empty ones would be better rather than just changing the behavior.

@pascalberger
Copy link
Contributor Author

@harshil93 Thanks for the feedback. I'll update the PR with a user checkbox. But propably will wait until #50 is merged and rebase on this.

@harshil93
Copy link
Member

@pascalberger The PR is merged. If you want to contribute to this. Go ahead.

@pascalberger
Copy link
Contributor Author

@harshil93 Since you have closed this issue do you already merge the PR (#48)? Otherwise the issue is not fixed...

@harshil93
Copy link
Member

@pascalberger I will try to get it merged by today. Reopening the issue till it get merged.

@harshil93 harshil93 reopened this Oct 21, 2016
harshil93 pushed a commit that referenced this issue Oct 21, 2016
* Set tokens to empty values if not set.
Fixes #24

* Add option for defining if empty values should be replaced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants