-1

I'm debugging an application in Ubuntu 20.04 with:

ltrace -e getenv ./cmd

I want to know which enviroment variables and their respective values are involved. I got surprised when I realized that there is an "empty name variable" without a value. There is the ltrace output:

....
    linux_a64.installos->getenv("")            = nil
    linux_a64.installos->getenv("TMPDIR")      = "/tmp"
    linux_a64.installos->getenv("DEBUGCMD")    = nil
....

Does anyone knows what this could be? There is a way to give an empty value to a enviroment variable?

  • 1
    What is `cmd`? It's not clear why it would call `getenv` with an empty string as its argument, but apparently it's not actually illegal. I'm not aware of any interpretation of the environment that allows a string that starts with `=` as part of the environment. – chepner Jun 09 '21 at 00:56
  • It's probably just some logic that operates on a value that was initialized to an empty string. Programmers generally prefer fewer special cases over avoiding unnecessary library calls. Why don't you attach a debugger and see where this call is made? – that other guy Jun 09 '21 at 01:05
  • `cmd` is a `setup` binary file. Apparently it only calls the installation GUI file through a simple command line: `"/media/virtualCD/installationGUI" "-CDpath" "/media/virtualCD/files/"` The problem is that when I type this command line direct in terminal, it works. But when this line is called by `setup` an error arises: `ERROR: Cannot wait for process "/media/virtualCD/installationGUI" "-CDpath" "/media/virtualCD/files/"` This worked perfect to me in older Ubuntu and Debian versions, and there not was this "empty variable name". This problem arises in Ubuntu 20.04. – Federico Rueda Jun 09 '21 at 02:15
  • I would not conclude from this that an empty environment variable exists on your system, although I think env names can be any string. From the trace, I just conclude that `cmd` is issuing a `getenv` call with the empty string as argument, and receives `nil` as an answer, because a variable with this name does **not** exist at this point. – user1934428 Jun 09 '21 at 06:44
  • 1
    For the same reason, I would conclude that `DEBUGCMD` is not present at the point of execution. BTW, to see all environment variables, I think `printenv` would be the tool of choice. – user1934428 Jun 09 '21 at 06:45

1 Answers1

1

Probably this environment variable wasn't set yet.

$ env | grep POTATO

$ echo $POTATO

You can get the environment variable value, even if that wasn't set before..

Lucas Mior
  • 68
  • 6
  • 2
    I think the OP is asking about the first line, where the *name* appears to be an empty string. – chepner Jun 09 '21 at 00:50