Hello Alexander, Jakub, and FLorian
On 10/20/18 12:42 PM, Jakub Wilk wrote:
Many strings (i.e., the environment and command line)
I guess this should be "e.g.", not "i.e."?
are in the internal format, with subfields terminated by null bytes
('\0'), so you may find that things are more readable if you use od
-c or tr "\000" "\n" to read them. Alternatively, echo `cat <file>`
works well.
Another part of this manpage suggests doing:
strings /proc/PID/environ
I changed this to:
cat /proc/1/environ | tr '\000' '\n'
which also isn't great: it won't print strings that are very short, and
it will truncate strings containing non-ASCII characters.
Indeed. The error was introduced by a patch that I should have
considered more carefully before I commited.
(commit 1391278030f64c7dd96f4535c1056321f690e094)
* Alexander E. Patrakov:
Unfortunately, echo `cat <file>` does not actually work:
[...]
Yes, I removed the line that suggested using cat(1).
* Florian Weimer <fw@xxxxxxxxxxxxx>, 2018-10-20, 11:49:
Huh. I'm surprised that it ever worked. This appears to do the job:
xargs -0 -n 1 < /proc/$$/environ
It runs echo under the covers, but I think the echo command line
syntax is such that at most, you will get no output for an "-n"
environment entry.
Yes, this should work for /proc/PID/environ, but /proc/PID/cmdline can
naturally contain "-n", and you wouldn't want it hidden.
I think the tr(1) command that I show does the right
things. Let me know if I'm wrong.
Thanks for the input, folks.
Cheers,
Michael