Strange errors

So I was testing my script and I got these errors

./sprttest2: line 177: declare: `xample.co': invalid variable name for name reference
./sprttest2: line 178: declare: `example.com_': invalid variable name for name reference
./sprttest2: line 179: declare: `example.com_redirect': invalid variable name for name reference

What is most confusing to me about these errors, is that the lines 177 through 179 don't try to declare anything as the errors would suggest, the first one is even empty!

The lines are:

if [[ -z $dirconf ]]
 then

What could be the cause of these errors?

Posted in: s/bash

๐Ÿš€ asdf

Mar 02 ยท 4 months ago

3 Comments โ†“

๐Ÿš€ asdf [OP] ยท Mar 02 at 09:51:

@HanzBrix what is a "process bracket"?

๐Ÿš€ asdf [OP] ยท Mar 02 at 11:33:

@HanzBrix I think that's a dollar sign followed by an opening squiggly bracket and a closing squiggly bracket, but Idk maybe they're not called that. Anyways, do you know how I can debug this error I keep getting on lines 190 and 152?

.: syntax error: operand expected (error token is ".")

There doesn't seem to be any dot that is just by itself, (in other words, surrounded by spaces), and I'm not sure which lines 152 and 190 are, since the errors don't seem to be reporting the same line numbers as nano does when I check what line I'm on.

Edit: According to Wikipedia those brackets are called braces, or curly brackets.

https://en.wikipedia.org/wiki/Bracket

๐Ÿš€ asdf [OP] ยท Mar 02 at 14:01:

@HanzBrix I'm not using any libraries, I think the only programs I'm using are the commands "file" and "cat", and the error persists if I comment those out. I did google what the word "typecast" means, and it said it means converting a variable from one type to another, (like a string into an integer for example). There is a part of the script that does that, but commenting it out made no difference.

Edit: I found it, it was actually on line 152, however I did not notice it since it didn't say ".", it said "ref", when it should have said "ref0".


Source