FS#71639 - [root] unclear error when attempting to run thisroot.sh
Attached to Project:
Community Packages
Opened by valentin v (vavolkl) - Wednesday, 28 July 2021, 11:33 GMT
Last edited by Konstantin Gizdov (kgizdov) - Friday, 26 November 2021, 12:51 GMT
Opened by valentin v (vavolkl) - Wednesday, 28 July 2021, 11:33 GMT
Last edited by Konstantin Gizdov (kgizdov) - Friday, 26 November 2021, 12:51 GMT
|
Details
Description:
The patched thisroot.* should have a clearer error message (when this file is sourced from another scripts the error message says something like "ERROR: bash should never be used") and actually only print a warning and not fail with an error, in order to work with scripts like this_dd4hep.sh Steps to reproduce: Running the tests of DD4hep. |
This task depends upon
But create a file "test.sh" with these two lines:
source /usr/bin/thisroot.sh
echo "do something with root ..."
and then run "source test.sh" - You'll see something like:
k4-arch-01: ~$ source test.sh
basename: invalid option -- 'b'
Try 'basename --help' for more information.
ERROR: should never be used!
Connection to k4-arch-01 closed.
depending on how the script is called, basename may print all kinds of things, none of them self-explanatory. A very easy fix that might save others hours of debugging is to just explicitly print:
fail "ERROR: thisroot.{sh,sh,fish} should never be used!" 1
instead of dealing with all the ways that basename can fail.
For the second part of the issue, consider that many people may have written scripts that use thisroot.* with the arch installation it is not necessary, which is great, but using fail means breaking all those scripts. Why not print a warning and make sourcing thisroot.* a noop?