Problem 2281

Summary: some example source files marked as executable
Product: Bugzilla Reporter: Stephan Lachnit <stephan.lachnit>
Component: generalAssignee: Gunter.Folger
Status: RESOLVED FIXED    
Severity: minor    
Priority: P4    
Version: other   
Hardware: All   
OS: Linux   

Description Stephan Lachnit 2020-10-29 11:04:42 CET
The following examples contain files marked as executable:

advanced/STCyclotron (random collection)
advanced/air_shower (*.mac files)
advanced/amsEcal (ams_ecal.pdf)
advanced/gammaknife (random collection)
advanced/hadrontherapy (random collection)
advanced/human_phantom (random collection)
advanced/iort_therapy (random collection)
advanced/medical_linac (random collection)
advanced/microbeam (random collection)
advanced/nanobeam (random collection)
advanced/xray_fluorescence (FlatSpectrum.dat)
extended/electromagnetic/TestEm3 (gamke* scripts, but they don't have a shebang anyway)
extended/exoticphysics/channeling (random collection)
... and many more in extended examples

A full list can be found here: https://mentors.debian.net/package/geant4/

This can occur when developing on Windows, however these files should not be executable at all. On Unix it can be fixed with:

chmod -x /path/to/examples/advanced/* /path/to/examples/extended/*

Some files in there are actual scripts, for example advanced/composite_calorimeter/envExample.sh, however they lack a shebang, so they can't be executed from a shell without specifying an interpreter anyway (i. e. `./envExample.sh` won't work, but `. ./envExample.sh` does work, even if not marked as executable).
Comment 1 Stephan Lachnit 2020-10-29 12:23:14 CET
While browsing the examples I found that whether scripts have a shebang or not and whether they are marked as executable or not is kinda random.

For example advanced/hadrontherapy/clean.sh doesn't have a shebang and is not marked as executable, extended/electromagnetic/TestEm10/test_suite.sh has a shebang and is marked as executable.

The simplest solution would be to make all of the executable again after making everything non-executable with the command mentioned before (however one might want to check that they all have an appropriate shebang).

A full list of all the scripts with an appropriate path ending in the examples can be retrieved with: find ./examples -regex '.*\.c?sh'
Comment 2 Gunter.Folger 2020-11-02 14:52:43 CET
Hello Stephan,
thanks for the report.

For most filetypes it should be straightforward to fix permissions. We'll try to address this in the upcoming release. 

For scripts however, our main platform is Unix, not Windows, thus the extension is only guidance, scripts can have any extension, notably none; therefore I'm afraid not all scripts will be .sh/.csh. 

Thanks again, also for the URL to the detailed report,
Gunter
Comment 3 Stephan Lachnit 2020-11-02 15:53:15 CET
Thanks for taking a look at this.

With `grep -Rl '^#!/' ./examples` you can find a list with every file beginning with a shebang line (i. e. scripts).
Together with `find ./examples -regex '.*\.c?sh'` for scripts without a shebang, it should be easy to find all scripts.
Comment 4 Gunter.Folger 2020-12-15 17:06:30 CET
Hello Stephan,
the permissions for all files in geant4 have been corrected, with the exception of one file in the advanced nanobeam example; the file OM50.grid is large, and we need to review if we will keep this as part of our git repositroy or if we distribute this with the web. 

I am closing this report, feel free to re-open if needed,
Gunter
Comment 5 Stephan Lachnit 2020-12-17 19:47:10 CET
Thanks!