I've defined an environment variable in the TextMate preferences with an all lowercase name. That environment variable is not available to my program/tests when I run RSpec inside TextMate. But when the first letter of the environment variable is a capital letter I do have access to it.
Is this a problem with TextMate or the RSpec bundle?
On 22 Oct 2015, at 13:46, Jacob Carlborg wrote:
I've defined an environment variable in the TextMate preferences with an all lowercase name. That environment variable is not available to my program/tests when I run RSpec inside TextMate. But when the first letter of the environment variable is a capital letter I do have access to it.
Is this a problem with TextMate or the RSpec bundle?
This is a convention enforced by TextMate.
The reason is that Preferences → Variables is really no different than ~/.tm_properties or any of the other ways to set “variables”.
The system is both used for settings and variables, and the convention is that the latter must start with an uppercase letter to be passed on to snippets, commands, etc.
On 2015-10-22 10:32, Allan Odgaard wrote:
This is a convention enforced by TextMate.
The reason is that Preferences → Variables is really no different than ~/.tm_properties or any of the other ways to set “variables”.
The system is both used for settings and variables, and the convention is that the latter must start with an uppercase letter to be passed on to snippets, commands, etc.
Hmm, it actually looks like command has access to the environment variable, i.e. this code [1], but not when it starts to execute the tests. It actually works if add this piece of code to line 13 [1]:
ENV['foo'] = ENV['FOO']
At this point, shouldn't the environment variables be passed down?
[1] https://github.com/rspec/rspec.tmbundle/blob/master/Commands/Run%20Focussed%...
On 23 Oct 2015, at 2:57, Jacob Carlborg wrote:
Hmm, it actually looks like command has access to the environment variable, i.e. this code [1], but not when it starts to execute the tests. It actually works if add this piece of code to line 13 [1]:
ENV['foo'] = ENV['FOO']
At this point, shouldn't the environment variables be passed down?
I don’t understand you.
Variables set in TextMate (via Preferences → Variables, .tm_properties, or bundle settings) are exported to snippets and commands if and only if the first letter is uppercase.
The code you show above is ruby code for copying the value of the ‘FOO’ environment variable into ‘foo’. Don’t see how that relates to what TextMate exports to a subprocess.
On 2015-10-23 08:22, Allan Odgaard wrote:
I don’t understand you.
Variables set in TextMate (via Preferences → Variables, .tm_properties, or bundle settings) are exported to snippets and commands if and only if the first letter is uppercase.
They are exported to commands even if the first letter is lowercase.
The code you show above is ruby code for copying the value of the ‘FOO’ environment variable into ‘foo’. Don’t see how that relates to what TextMate exports to a subprocess.
Let's see if I can explain this:
1. TextMate executes a command in the RSpec bundle 2. That command is implemented in bash, containing inline Ruby code. That is, Ruby code is piped to a file which is then executed 3. The Ruby code runs the tests
All variables (defined in Preferences → Variables), regardless of case, are available at step 2. But only environment variables starting with a capital letter are available in step 3.
On 24 Oct 2015, at 2:41, Jacob Carlborg wrote:
Let's see if I can explain this:
- TextMate executes a command in the RSpec bundle
- That command is implemented in bash, containing inline Ruby code.
That is, Ruby code is piped to a file which is then executed 3. The Ruby code runs the tests
All variables (defined in Preferences → Variables), regardless of case, are available at step 2. But only environment variables starting with a capital letter are available in step 3.
That is not the case here. I made the following command:
#!/bin/sh env|grep -v '^[A-Z]'
I see two variables starting with underscore, but no underscore variables, even though I added one in Preferences → Variables.
On 2015-10-24 08:31, Allan Odgaard wrote:
That is not the case here. I made the following command:
#!/bin/sh env|grep -v '^[A-Z]'
I see two variables starting with underscore, but no underscore variables, even though I added one in Preferences → Variables.
Sorry, I don't know what I was thinking. My workaround was to declare the variable with a capital letter in Preferences → Variables and then assign it with a lowercase letter in the actual command.
Sorry for the noise.
BTW, is there a reason why the settings in ~/.tm_properties shouldn't be available to commands and snippets?
On 24 Oct 2015, at 16:48, Jacob Carlborg wrote:
BTW, is there a reason why the settings in ~/.tm_properties shouldn't be available to commands and snippets?
The settings can be queried using the tool available via the TM_QUERY environment variable.
For usage press ⌃R on a line containing: "$TM_QUERY" --help
You can also run it w/o arguments to dump all settings from current context.
The settings are not exported as variables because I think that would be polluting the global environment and some settings could easily clash with actual variables, e.g. TextMate has an “encoding” setting.
On 2015-10-24 12:12, Allan Odgaard wrote:
The settings can be queried using the tool available via the TM_QUERY environment variable.
For usage press ⌃R on a line containing: "$TM_QUERY" --help
You can also run it w/o arguments to dump all settings from current context.
Aha, cool. I didn't know about this tool. Thanks.
The settings are not exported as variables because I think that would be polluting the global environment and some settings could easily clash with actual variables, e.g. TextMate has an “encoding” setting.
Fair enough, I just didn't know about the tool.