Check duplicate issues.
Description
thisroot.sh doesn't check that the found SOURCE actually contains thisroot.sh before using it to set ROOTSYS. I've checked and the relevant lines on "master" don't seem to have changed.
Reproducer
This can be reproduced from the command line using
cd # don't be in the root source
cat [location of root]/bin/thisroot.sh | /usr/bin/dash
(substitute the path to root). On my system the exact command is:
cd
cat work/t2k/software/nd280-v14.38/ROOT_6.32.02.03/Linux-Debian_13-gcc_14-x86_64/bin/thisroot.sh | /usr/bin/dash
ROOT version
ROOT v6.32.02
Built for linuxx8664gcc on Dec 23 2025, 19:07:20
From heads/master@tags/v6-32-02
With c++ (Debian 14.2.0-19) 14.2.0
Binary directory: /home/mcgrew/work/t2k/software/nd280-v14.38/ROOT_6.32.02.03/Linux-Debian_13-gcc_14-x86_64/bin
Installation method
Built from source using T2K build wrapper
Operating system
Linux Debian 13.2
Additional context
Using thisroot.sh inside a Makefile (generated by cmake) on debian 13 where "/usr/bin/sh" is linked to "dash" causes
x=$(lsof -p $$ -Fn0 2>/dev/null | tail -1); # Paul Brannan https://stackoverflow.com/a/42815001/7471760
SOURCE=${x#*n}
to return /dev/pts/0 (expected since Brannan's fix isn't completely portable, and there's probably no way to make it work everyplace), leaving SOURCE pointing to /dev.
This can be handled by checking that SOURCE contains thisroot.sh. For instance, add:
# Check to see if the right directory was found (near thisroot.sh line 238)
if [ ! -f ${thisroot}/../bin/thisroot.sh ]; then
echo SOURCE IS ${SOURCE}
echo DID NOT FIND thisroot.sh at ${thisroot}/../bin
return 1
fi
before using ${thisroot} to set ROOTSYS. The thisroot.sh script will fail, but it doesn't leave ROOTSYS pointing to the wrong location, which is probably the best that can be hoped for on a pure posix shell and an odd setup.
Check duplicate issues.
Description
thisroot.shdoesn't check that the foundSOURCEactually containsthisroot.shbefore using it to setROOTSYS. I've checked and the relevant lines on "master" don't seem to have changed.Reproducer
This can be reproduced from the command line using
(substitute the path to root). On my system the exact command is:
ROOT version
Installation method
Built from source using T2K build wrapper
Operating system
Linux Debian 13.2
Additional context
Using thisroot.sh inside a Makefile (generated by cmake) on debian 13 where "/usr/bin/sh" is linked to "dash" causes
to return
/dev/pts/0(expected since Brannan's fix isn't completely portable, and there's probably no way to make it work everyplace), leaving SOURCE pointing to /dev.This can be handled by checking that SOURCE contains
thisroot.sh. For instance, add:before using
${thisroot}to set ROOTSYS. The thisroot.sh script will fail, but it doesn't leave ROOTSYS pointing to the wrong location, which is probably the best that can be hoped for on a pure posix shell and an odd setup.