run with new group credentials - KineticTheory/Linux-HPC-Env GitHub Wiki

Summary

I use this small bit of code at the top of many shell scripts to ensure any artifacts generated by the script have the desired permissions.

# execute the remainder of this script as group 'foo'
if [ $(id -gn) != foo ](/KineticTheory/Linux-HPC-Env/wiki/-$(id--gn)-!=-foo-); then
  exec sg foo "$0 $*"
fi
# Full access for _User_, Read and Execute for _Group_, No access for _World_.
umask 0027