Bad: Modifier in $ (.)

Bad : modifier in $ (/)

As Ignacio Vazquez-Abrams, pointed out you need to set environment variable in tcsh syntax as

setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:"/home/my/lib"

Bad : modifier in $ ($)

csh allows variable modifiers in the form of $varname:x, where x is a letter. Some examples are :e to get the extension, :q to quote the string, and a whole bunch more. For example:

> set path = 'file.txt'
> echo $path:e
txt

The problem you're running in to is that this:

setenv PYTHONPATH $CTH_PYTHONPATH:$PYTHONPATH

That the same syntax: $CTH_PYTHONPATH ends with a :, so it tries to apply the $ modifier, but this modifier doesn't exist so you get the error:

Bad : modifier in $ ($).

The solution is to use ${varname} to explicitly tell csh when the variable name ends or using quotes:

setenv PYTHONPATH ${CTH_PYTHONPATH}:${PYTHONPATH}
setenv PYTHONPATH "$CTH_PYTHONPATH":"$PYTHONPATH"

I recommend quoting variables by the way; it will prevent problems with spaces and the like; I'd probably write this as:

setenv PYTHONPATH "${CTH_PYTHONPATH}:${PYTHONPATH}"

Note that I don't recommend using csh if you can help it by the way; it's an old shell with a lot of problems, including strange errors in all sorts of cases. Note how the error you have doesn't print the line number or is really very helpful.

tcsh: Bad : modifier in $ ( )

Ended up using

set Y = `echo $* | awk -F " " '{print $NF}'`

instead for my last argument, and this is compatible with tcsh. Solved it for me!

Bad: modifier error when installing RVM

Are you in any case running a shell that is not Bash or ZSH? Bash >= 3.2.25 or ZSH >= 4.3.10 is required.

Your problem looks like you were using minimalistic shell sh which is not supported by RVM.

You can check user shell in /etc/passwd and change it with chsh -s /path/to/new/shell - list of allowed shells is available in /etc/shells - but make sure to pick Bash/ZSH, also note that links like sh->bash will not work as bash changes behavior based on the name that was invoked.

Java default modifier in compilation

Looking at The class File Format, especially section 4.5 Fields and 4.6 Methods I see the following constants being defined:

ACC_PUBLIC     0x0001
ACC_PRIVATE 0x0002
ACC_PROTECTED 0x0004

However, a specific method (field) of a class may have at most one of its ACC_PRIVATE, ACC_PROTECTED, and ACC_PUBLIC flags set (JLS §8.3.1).

Since there is no ACC_DEFAULT flag and the documentation says at most one (not exactly one) I would guess that having no flags at all means default access.

Makefile macro modifier

TOOL_ROOTS must be getting assigned some value other than the empty string at some point or that does nothing (which I'll show in a moment).

So first things first just expanding the variables takes us from:

TOOLS = $(TOOL_ROOTS:%=$(OBJDIR)%$(TOOL_SUFFIX))

to:

TOOLS = $(:%=~/obj%.so)

(which we can immediately see doesn't look right, and as I'll explain in a moment doesn't do anything)

So lets pretend it has a value instead.

TOOL_ROOTS = shovel axe hammer

And try the expansion again:

TOOLS = $(shovel axe hammer:%=~/obj%.so)

(That OBJDIR definition looks odd also. I would expect it to be ~/obj/ or something... and that's ignoring that ~ is a bad choice here and that $HOME would be much better.)

The next thing we need to know is what that syntax is all about. Well it is a Substitution Reference.

A substitution reference substitutes the value of a variable with alterations that you specify. It has the form ‘$(var:a=b)’ (or ‘${var:a=b}’) and its meaning is to take the value of the variable var, replace every a at the end of a word with b in that value, and substitute the resulting string.

When we say “at the end of a word”, we mean that a must appear either followed by whitespace or at the end of the value in order to be replaced; other occurrences of a in the value are unaltered. For example:

foo := a.o b.o c.o
bar := $(foo:.o=.c)

sets ‘bar’ to ‘a.c b.c c.c’. See Setting Variables.

A substitution reference is actually an abbreviation for use of the patsubst expansion function (see Functions for String Substitution and Analysis). We provide substitution references as well as patsubst for compatibility with other implementations of make.

Another type of substitution reference lets you use the full power of the patsubst function. It has the same form ‘$(var:a=b)’ described above, except that now a must contain a single ‘%’ character. This case is equivalent to ‘$(patsubst a,b,$(var))’. See Functions for String Substitution and Analysis, for a description of the patsubst function.

For example:

foo := a.o b.o c.o
bar := $(foo:%.o=%.c)

sets ‘bar’ to ‘a.c b.c c.c’.

So, the first % there is matching the entirety of every word in the value of the variable (here shovel axe hammer) and then replacing each value with the expansion of the second part.

So shovel becomes ~/objshovel.so, etc. and we end up with:

TOOLS = ~/objshovel.so ~/objaxe.so ~/objhammer.so

See what I meant about OBJDIR being odd before? OBJDIR=~/obj/ would have left us with this instead:

TOOLS = ~/obj/shovel.so ~/obj/axe.so ~/obj/hammer.so

which makes a lot more sense to me.



Related Topics



Leave a reply



Submit