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

Non-obvious variable assignment issues #84

Closed
alexwhitman opened this issue Jan 11, 2022 · 1 comment · Fixed by #85
Closed

Non-obvious variable assignment issues #84

alexwhitman opened this issue Jan 11, 2022 · 1 comment · Fixed by #85
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request syntax

Comments

@alexwhitman
Copy link
Contributor

let SOME_VAR = "123"
log {
	name => "log-one"
	message => "one - ${SOME_VAR}"
	require => "log-two"
}

let SOME_VAR = "abc"
let COMMAND_RESULT = `find /tmp`
log {
	name => "log-two"
	message => "two - ${SOME_VAR}"
	unless => set("${COMMAND_RESULT}")
}

The above will output

2022/01/11 13:21:35 [USER] two - 123
2022/01/11 13:21:35 [USER] one - 123

There are two issues here.

  1. People may think that two - abc should be logged by looking at the definition. It's understandable why it doesn't but it's non-obvious. This may be something that's just accepted and documented as a known limitation.

  2. The bigger issue is where the execution is conditional. With the removal of backtick execution from conditionals, log-two in the example ran because COMMAND_RESULT is empty at the point of execution, only after is find /tmp run and /tmp is unlikely to be empty. Now this came from the move to the AST based approach but I think backtick execution would need to make a come back.

@skx
Copy link
Owner

skx commented Jan 11, 2022

Agreed on both points - and I suspect the variable thing just needs to be documented a little more explicitly and then tolerated.

I'll get backtick support back in the next night or two.

@skx skx self-assigned this Jan 11, 2022
@skx skx added documentation Improvements or additions to documentation enhancement New feature or request syntax labels Jan 11, 2022
@skx skx mentioned this issue Jan 11, 2022
@skx skx closed this as completed in #85 Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants