#236: GetComponents should abort on undefined variables -------------------------------------+-------------------------------------- Reporter: knarf | Owner: Type: defect | Status: new Priority: minor | Milestone: Component: EinsteinToolkit website | Version: Keywords: | -------------------------------------+-------------------------------------- Hi,
I just combined two thornlists and "lost" (forgot) the definition of $ARR in the process. GetComponents used this thornlist and started to checkout stuff, into the current directory. It should probably abort in the case of undefined (but used) variables, shouldn't it? Could this lead to problems?
#236: GetComponents should abort on undefined variables ----------------------------+----------------------------------------------- Reporter: knarf | Owner: eric9 Type: defect | Status: new Priority: minor | Milestone: Component: GetComponents | Version: Resolution: | Keywords: ----------------------------+----------------------------------------------- Changes (by knarf):
* owner: => eric9 * component: EinsteinToolkit website => GetComponents
#236: GetComponents should abort on undefined variables ----------------------------+----------------------------------------------- Reporter: knarf | Owner: eric9 Type: defect | Status: accepted Priority: minor | Milestone: Component: GetComponents | Version: Resolution: | Keywords: ----------------------------+----------------------------------------------- Changes (by eric9):
* status: new => accepted
Comment:
Did it not even report a Perl error, a la 'use of uninitialized variable?' Regardless, you're right that we should be checking for this somehow while parsing the thornlist.
#236: GetComponents should abort on undefined variables ----------------------------+----------------------------------------------- Reporter: knarf | Owner: eric9 Type: defect | Status: accepted Priority: minor | Milestone: Component: GetComponents | Version: Resolution: | Keywords: ----------------------------+-----------------------------------------------
Comment (by eric9):
Ok, I see what's going on here. Since $ARR is not defined, !GetComponents treats it as a legitimate directory name and attempts to check the thorns into Cactus/$ARR/xxx. Then the shell obviously decides that $ARR is not defined and gets rid of it, so I end up with Cactus/xxx. This presents an interesting problem because, technically, '$ARR' is a valid directory name, although I doubt that anyone actually names their folders like that.
So I see two possible solutions:
1. Force the $ sigil to indicate a variable and throw an error if it was not previously defined. This would be very clean and prevent issues of the type you saw; however, if someone happens to prefix some folders with a $, they would be out of luck...
2. Allow the $ sigil to be used NOT referring to a variable. Any paths of this type would have to be explicitly single-quoted; this could probably be handled by !GetComponents itself though. I think I could just add some logic to automatically enclose any paths in single-quotes before executing a command, which should change nothing outside of odd cases like this.
Since this would mean altering the behavior of !GetComponents, we should probably ask for comments on the mailing list as well.
What do you think?
#236: GetComponents should abort on undefined variables ----------------------------+----------------------------------------------- Reporter: knarf | Owner: eric9 Type: defect | Status: accepted Priority: minor | Milestone: Component: GetComponents | Version: Resolution: | Keywords: ----------------------------+-----------------------------------------------
Comment (by knarf):
I don't think that anyone would choose directory names starting with '$', however, if possible I wouldn't make it impossible to use them. In addition, someone could actually try to use an environment variable. Could GetComponents do this: produce a warning/error if an undefined $VAR is detected _and_ no environment variable of that name is defined. If an env- variable is defined: let the shell deal with it. Otherwise error out because the use of a simple, unescaped '$' without a CRL definition or an environment variable has to be a mistake and would not work in any case. I would then make '$' escapeable by '$', or single quotes.
#236: GetComponents should abort on undefined variables ----------------------------+----------------------------------------------- Reporter: knarf | Owner: eric9 Type: defect | Status: accepted Priority: minor | Milestone: Component: GetComponents | Version: Resolution: | Keywords: ----------------------------+-----------------------------------------------
Comment (by eric9):
That sounds reasonable. I'll try to look into it this weekend :)
#236: GetComponents should abort on undefined variables ----------------------------+----------------------------------------------- Reporter: knarf | Owner: eric9 Type: defect | Status: closed Priority: minor | Milestone: Component: GetComponents | Version: Resolution: fixed | Keywords: ----------------------------+----------------------------------------------- Changes (by eric9):
* status: accepted => closed * resolution: => fixed
Comment:
Sorry this one took a while... GetComponents will now send escaped variables to the shell. If they are undefined, it will error out immediately. For now, you have to use a backslash to escape variables, but I can work on adding single quotes too if you want.
trac@lists.einsteintoolkit.org