On my Debian/unstable machine, I wanted to generate a nvidia-bug-report.log.gz file using nvidia-bug-report.sh from the nvidia-driver-bin 375.82-1 Debian package, but among the log files
-rw-r--r-- 1 root root 32848 2017-08-23 13:48:41 /var/log/Xorg.0.log
-rw-r--r-- 1 root root 50925 2017-08-23 12:22:11 /var/log/Xorg.0.log.old
-rw-r--r-- 1 root root 34928 2015-06-29 17:50:40 /var/log/Xorg.1.log
-rw-r--r-- 1 root root 34911 2015-06-29 17:49:05 /var/log/Xorg.1.log.old
I noticed that /var/log/Xorg.0.log.old (which contained the error) was not included.
I looked at the nvidia-bug-report.sh script and found:
for log_basename in /var/log/XFree86 /var/log/Xorg; do
for i in 0 1 2 3 4 5 6 7; do
for log_suffix in log log.old; do
log_filename="${log_basename}.${i}.${log_suffix}"
append_silent "${log_filename}"
so that /var/log/Xorg.0.log.old should have been included… but in the loop body, one has:
append_glob "$j/*.conf"
and this function is defined as:
append_glob() {
for i in `ls $1 2> /dev/null;`; do
append "$i"
done
}
As you can see, the variable i is reused (in shells, variables are not local by default), so that when the above function is run with log_suffix=“log”, the variable i will not have the expected value for log_suffix=“log.old”.