(Screenshot of the problem)
It was working properly but now I am not able to declare any variable at all. by the $ symbol.
Related
The help text for set -a is somewhat cryptic to me, but maybe i just don't understand what bash is doing behind the scenes with variables. Can someone explain why "marking" variables is needed (what are "unmarked" variables)?
My bash man-page uses a slightly different wording for this: Each variable or function that is created or modified is given the export attribute and marked for export to the environment of subsequent commands. This sounds more clear to me. It means:
Each variable you define in your script, is placed in the environment of any child process you create, and each function you define is also available to each bash-child-process you create.
I save the variable in .dir-locals.el like this:
(add-dir-local-variable 'nil 'CurrentProjectStat CurrentProjectStat)
(save-buffer)
(kill-buffer)
When I upload a file with a given project, this variable is loaded only for this buffer, but I need it to be loaded globally. I use this variable in the form of widgets, this is a different buffer, and this variable is no longer there.
I do not know in which direction to look, overriding the variable does not help.
Tell me please how to make such a variable global?
For the sake of answering the question as stated:
You can use the pseudo-variable eval to evaluate arbitrary code, and therefore set a non-local variable (assuming the variable is not already buffer-local), like so:
((nil . ((eval . (setq GLOBALVAR VALUE)))))
I strongly doubt that this is actually what you want to do, however.
Is it possible to Highlight bash internal varibles using VIM?
For example the variables described on this page would appear a different colour than the user defined variables.
http://tldp.org/LDP/abs/html/internalvariables.html
You can define additional syntax keywords for those built-in variables. Put the following into ~/.vim/after/syntax/sh.vim:
syntax keyword shBuiltInVariable BASH BASH_ENV BASH_VERSION containedin=shDerefSimple
highlight def link shBuiltInVariable Special
The containedin= is necessary because shell variables are already parsed by existing syntax groups, and these additional overrides need to go in there to match.
Also note that $VIMRUNTIME/syntax/sh.vim supports multiple shell dialects; if you use different shells, you need to add proper conditionals (b:is_bash etc.) around your additions.
In a makefile I'm reading, there are many references to a variable, projdir, defined and exported in the shell script that calls make; there are many instances of $(projdir) in the makefile.
From the make manual at http://www.gnu.org/software/make/manual/make.html#Reference, there are only two types of variables: recursively expanded variables and simply expanded variables. It seems projdir is neither one.
Question 1: Since the makefile works, it must be true that makefiles can access shell variables defined in the parent shell environment. Why is this not documented (or perhaps I did not find the correct documentation)?
Question 2: Unrelated to question 1, I see in Section 6.2 the line all:;echo $(foo). Why is the semicolon ; needed here?
Question 1. Environment variables automatically become make variables. This is explained in section 6.10:
Variables in make can come from the environment in which make is run. Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value.
Question 2: Putting a semicolon after a rule name and optional prerequisites allows you to start the recipe on the same line. This is explained in section 4.2:
The first recipe line may appear on the line after the prerequisites, with a tab character, or may appear on the same line, with a semicolon.
They used this syntax in the example in 6.2 for brevity, so they could show the whole rule inline in the sentence; I think it's rarely used in practice.
From the make manual:
Variables in make can come from the environment in which make is run. Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value.
As to your second question:
Why is the semicolon ; needed here?
Without the semicolon the right-hand side of : would specify the list of dependencies. The semicolon terminates that (empty) list.
Variables have both a flavor and an origin.
Expansion type is a flavor.
make contains a flavor function which can be used to find the type of variable in question. It will return one of undefined, recursive or simple.
Variables also have an origin which is where their value has come from. What you are seeing here is one of those possible origins.
The origin function will tell you the origin of a variable.
There are seven possible origins: undefined, default, environment, environment override, file, command line, override and automatic.
So your projdir variable has a flavor of simple and an origin of environment.
In the freemarker template language, I can test whether a variable exists by using constructs like variable?exists or variable??. I can also cause a previously non-existent variable to exist by assigning to it, e.g., <#assign variable = "hi" />. But how can I cause a previously existing variable to no longer exist?
I have some other dude's freemarker template, with logic at various points that tests for the (non-)existence of certain variables. In my use case, it would be simplest if I could have a variable that exists at one point, then becomes undefined when including his template, then gets assigned to again later on. The alternative is to restructure things more significantly.
No, there's no directive fort that. Maybe it can be achieved with a custom directive (TemplateDirectiveModel) that can then write null into the variable through the Environment. (Unless the Environment API checks for null-s...)