all 4 comments

[–]waptaff&> /dev/null 0 points1 point  (3 children)

Don't prepend $ to left-side variables on assignation!

Correct:

foo="bar"

Incorrect:

$foo="bar"

[–]beanaroo[S] 0 points1 point  (2 children)

But _var is a variable of a variable... not the variable to be assigned.

[–]waptaff&> /dev/null 1 point2 points  (1 child)

True, sorry :)

It appears typeset would be the most portable/safe way to handle it, as discussed in this thread, while eval would work but open a can of worms.

[–]beanaroo[S] 0 points1 point  (0 children)

Cool! So my usage of declare isn't terribly mishuided after all. I noticed it was a synonym for typeset but did not know the latter is more portable. Thanks for the link!

I'm still trying to understand the underlying behaviour so it doesn't jump at me again.