-
Notifications
You must be signed in to change notification settings - Fork 294
Can't use "$" (dollar-sign) char in snap task files #1691
Comments
Good catch @michep, we'll add this to our backlog. Though if you have a fix in mind, go ahead and submit a PR. We appreciate all contributions. |
Approach to resolve this issue is depend on how current functionality supposed to work. Why, in the first place, it was implemented. Is it really necessary to use environment variables expansion in tasks? One way is to use regexp |
@michep, do you mind sharing your task file with me? I am curious to see where exactly you are using the command |
This is all about my plugin - https://github.com/michep/snap-plugin-processor-maptag |
Hello @michep, I see your point that you want to directly pass e.g.
See full example here In your case, you need to pass a value of config param (which includes a dollar char) in a different way, not directly. @michep, do you need help in that? |
Hi, @IzabellaRaulin. So, what is that other, indirect way? |
@michep - one way is providing in task manifest a path to file in which you can have the dollar sign. What is more, you as an author of plugin can decide what this structure of the file should look like - it might be just one line file with a command or some json/yaml when user can declare more params, depending on needs. Example 1 - where command.txt has one line containing the command
As a value of config you receive path to command file, so in plugin needs to be handled opening this file and interpreting its contents. Example 2 - where setfile.yaml contains all possible parameters with determined its value (notice that there are no param2, neither param3. All config parameters might be determined in setfile.yaml together with command.
Please, let me know if this has sense in your use case and what do you think about it . |
Following the Occam's razor principle one should not create new entities until this is truly necessary. |
Hello @michep, sorry for delayed response. I think your proposition is valuable. I look on python's os.path.expandvars() and I agree that similar approach should be considered in Snap. I will create RFC and describe the proposition, just to summarize our discussion and continue design discussion under new GH issue. It would be great if you would like to contribute to that. Thank You. |
Due to calling
os.ExpandEnv()
insnap\core\task.go:331 [func UnmarshalBody()]
and insnap\cmd\snaptel\task.go:355 [func createTaskUsingTaskManifest()]
it is not possible to use "$" char in snap task files, it will be unconditionally removed, and there is no way to escape this symbol.Example here.
Now Im creating a processor plugin in which one can specify command line to execute, and if it contains "$" char in it, like
cat /etc/fstab |grep ext[2,3,4]| awk '{print($2);}'
, it will be broken.The text was updated successfully, but these errors were encountered: