Last week I posted about problems with dashes in shell variable names.
I'm still having to use an app that needs them, but I was encouraged by
several of you to use the "env" commmand: env my-var=myvalue myprog
[args] . This works just great. However, if "myprog" happens to be
"sh" or if myprog spawns sh somewhere in its execution, it errors out.
Example (myprog is a test C program):
bash$ env my-var=hello myprog
in myprog, getenv("my-var") is 'hello' .
bash$ env my-var=hello sh
my-var=hello is not an identifier.
bash$ env myvar=hello sh
So, if I take out the dash, sh executes, and I'm left at the sh prompt.
If there's a dash in the variable name, though, sh won't run. So, my
main problem is that some of the "myprogs" out there will spawn shells
as part of their execution, and when they do those shells will fail.
One more note:
bash$ env my-var=hello bash
(If I spawn a bash and not sh, things are fine).
Yes, I have read the entire man pages for sh and env, but I haven't
found anything that helps me here.
Thanks very much,