I'm trying to use the sshrc to execute fish with my own defined functions at the remote server.
I know there is a $fish_function_path variable that I can modify to prepend my custom path with my functions, but this variable seems global and I don't want to affect other fish users.
Is there any way to change this variable only for my single fish session or any other ways to use my fish functions only for a single session?
I have also tried setting and environment variable from the outer shell: fish_functions_path="$MY_FUNCTIONS_PATH" fish but it seems environment variables don't affect those inner variables of fish.
Used this docs.
Thanks!
Global variables, including $fish_function_path, are per-session. You might be thinking of universal variables, which are shared across sessions for a given user.
It should be fine to modify $fish_function_path for a given instance of fish - it won't affect any others.
Related
When I make a preload script in godot and put a variable in there, how do I call the variable in my other scripts?
Is there a special way to call the variable that I don't know or is there a better way to do it than preload scripts?
If you are preloading a script, e.g. const item = preload("res://scripts/item.gd") it acts as a type. That is, you can declare variables as it, and make instances of it. The variables declared on the script exist on its instances:
const Item = preload("res://scripts/item.gd")
var my_item:Item
func _ready():
my_item = Item.new()
print(my_item.variable)
See Custom variable types and Classes and nodes. By the way, no, there are no static variables in Godot, see "static" on Keywords table.
You could be preloading a scene instead of a script. In that case you get a PackedScene, similar rules apply. But you would be using the instance method.
Instead of doing this, I suggest to give a class_name to your script. Godot will recognize it and make it available everywhere. See Register scripts as classes.
Please note that this is different from accessing a variable defined on another node in the scene tree. If you are trying to access a variable defined in the script of another node in the scene tree, the use get_node or similar to access the node, and then you can access the variable on it. See Understanding node paths.
If you need a global variable, what you want is an "singleton" autoload. You can set a scene to autoload in the "AutoLoad" tab in your project settings (select the scene path, give it a name, and click "Add"). They will be available on the scene tree regardless of the scene. They persist changes of scene.
Since autoloads are on the scene tree, you can use get_node to access them. The path will "/root/" followed by the name you gave it. For example:
onready var global_variables = get_node("/root/GlobalVariables")
func _ready():
print(global_variables.variable)
If you want to have access to one script from 1 or more different scripts, It is not a good way to use preload script. (at least in my opinion)
I prefer to make an script, global in the project and have access to that script from other scripts and nodes.
Now how to do that?
Open a new or a prefered scene.
On top menu, under project scroll, click on Project Settings.
On Project Settings, click on Autoload tab and add the script that you want to have access to from everyscript in the game and ofcourse add a fine Node Name to it.
Now based on that Node Name, you can have access to anything inside that global script.
For example, if this is my global script that I Autoloaded it as Global node name:
extends Node
var num: int = 5
I can have access to num variable from every other scripts like:
Global.num = 6
Make sure to take a look at the AutoLoad Documentation for more info.
I need to use a variable between node modules folder and src folder.Is there a way to use a variable to be used within the whole project?
Thanks.
Typically this is done with process environment variables. Any project can look for a common environment variable and handle that case accordingly, as well as the node modules of said project. As long as they agree on the name, they all share the same environment. Have a good default, don't force people to set this environment variable.
The environment can be set using an environment file (do not check this into source control!), on your container or cloud configuration, or even right on the command line itself.
TLOG=info npm test
That is an example that I use frequently. My project runs logging for the test cases only at alert level - there are a lot of tests so it makes the output less verbose. However, sometimes while developing I want to see all the logs, so my project is looking for an environment variable TLOG (short for "test logging") and I can set it just for that run! Also no code change is needed, which is nicer than JavaScript variables that need to be set back to original values, forget to be turned off, etc.
I read and verified that I can pass environment variables to node by doing something like:
MY_ENV_VAR1=/tmp MY_ENV_VAR2=/data node index.js
How on earth does that work? I've only seen arguments to a script come after the script name, not before.
Thanks!
That is the standard way of defining and passing on the environment variables to a particular command from a Linux shell w/o exporting it.
More details: https://unix.stackexchange.com/questions/158117/how-to-pass-environment-variables-to-a-non-interactive-shell-with-example
Any environment variable prefixed with "FACTER_" is automatically added to the facter collection. I've successfully added a "FACTER_" environment variable it is indeed showing up in the facter -p list, so it should be able to be used by puppet...
The problem, though, is in my .pp file the variable name that should be set to the FACTER_ value is empty (or non existant)
Is there something else I need to do to get FACTER_ variables into puppet variables?
Cheers
You are most likely setting up the system so that the FACTER_ variables are available in interactive shells. This is not sensible if you want your background agent to respect them.
I can see two direct approaches:
Modify your initscript or its configuration to set the appropriate environment variables.
Forego the approach entirely and use /etc/facter/facts.d instead.
I would advise towards the latter.
After installation of Ruby Version Manager (RVM) as root on an Ubuntu 14.04. I am confronted with a strange behaviour of bash. Let's have a look at the exported environment variables. I login as user ubunutu and run exportin my bash. Here are three of rvm's exported environment variables, others are available:
declare -ax chpwd_functions='([0]="__rvm_cd_functions_set" [1]="__rvm_after_cd")'
declare -x rvm_version="1.25.28 (stable)"
declare -x rvm_ruby_mode
Everything is pretty fine, but when I run bash -c export we get only:
declare -x rvm_version="1.25.28 (stable)"
Can someone explain me why all empty environment variables and all arrays are removed in the child bash? What must I do to ensure that really all environment variables of a parent shell are available within a child shell?
This problem is really a blocker for me. I am using vagrant and its shell provisioner. In one script I setup rvm and in a second one I must configure some gemsets. The problem is that in the second script the rvm commands do not run. The active shell only gets those environment variables of rvm with are non-arrays and non-empty. Manually sourcing of rvm.sh is no solution!
It is because as per last line of man bash:
Array variables may not (yet) be exported.
I read somewhere a note by BASH developer that it is because exporting an array is very complex and error prone.
Also this line:
declare -x rvm_ruby_mode
is only declaring a name of the variable with export attribute set (without value), if you assign it a value it will be available in the sub shell.
Here is post by BASH author on export of array in BASH.
A variable is created when a value is assigned to a name using the = operator, for example
foo=bar
creates a variable named foo with the value bar.
declare is used for two reasons: one, to allow dynamic creation of variables (which is beyond the scope of this question), and two, to set attributes on names (not necessarily variables). The command
declare -x rvm_ruby_mode
simply sets the export attribute of the name rvm_ruby_mode. To actually create a variable whose name has the export attribute set, you need to use the = operator, just as without the declare command.
declare -x rvm_ruby_mode=
Now rvm_ruby_mode is an empty variable whose named is marked for export.
I say "marked for export" because variables are not exported until a subshell is created. Until then, there is simply a list of names that, if the name has a value when a subshell/child process is created, are copied into the new environment. This list is separate from the list of actual variables (which again are names with associated values).
As to why arrays cannot be exported? The environment is technically not a set of variables, since a variable is a shell construct and the environment is something used by all processes in POSIX, whether or not run by a shell. The environment is simply a list of strings of the form <name>=<value>. There is no standard for how to pack the elements of an array into a single string which any process can parse and reconstruct into an appropriate data structure. While it's possible that bash could make an exception if it new the child process was another bash shell and come up with some way of embedding an array in the environment (like it does with function definitions), apparently this has not been done.