From 438e1970093621d3c67acc900b17afdeaa60329f Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Tue, 5 Feb 2019 18:19:46 +0000 Subject: for-group: better check of group name and fixed make argument A few issues came up while testing the `for-group' script in one of the projects based on this pipeline that are being fixed with this commit: 1) We are ultimately using the `sg' command to use the specified group, not `chgrp'. So in cases where `chgrp' has problems, this would cause a wrong error. So for the test of the given group's existance, we are now directly calling `sg'. 2) In the call to `make' we were mistakenly giving make the `$2' (which is `make' on the command-line) argument. Since `./for-group' now takes the group name as its first argument, this should have been `$3'. 3) To help in readability, and also allow for group names with a space, `reproducible_paper_group_name' is now defined and exported before the final call to `sg'. --- .file-metadata | Bin 3666 -> 3666 bytes for-group | 14 +++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.file-metadata b/.file-metadata index 11686e3..b5d861e 100644 Binary files a/.file-metadata and b/.file-metadata differ diff --git a/for-group b/for-group index 1d96fc3..4ada15f 100755 --- a/for-group +++ b/for-group @@ -57,16 +57,19 @@ if [ "x$1" = x ]; then exit 1 fi + + + + # Make sure the given group is usable. testfile=".reproducible-pipeline-group-test" -echo "Just for a test" > $testfile -if chgrp $1 $testfile; then +if sg "$1" "echo test > $testfile"; then rm $testfile if [ "x$2" = xconfigure ]; then script="./configure" - elif [ "x$2" = xmake ]; then script=".local/bin/make $2" + elif [ "x$2" = xmake ]; then script=".local/bin/make $3" else echo "$0: a third argument is necessary." - echo "It specifies the action: 'configure' or 'make'" + echo "It specifies the action: either 'configure' or 'make'" exit 1 fi else @@ -87,4 +90,5 @@ fi # We are also exporting a special variable so `./configure' and Make can # prepare for sanity checks and avoid re-doing the whole analysis with a # typo (not using this script properly after configuration). -sg $1 "umask u+r,u+w,g+r,g+w,o-r,o-w,o-x && export reproducible_paper_group_name=$1 && $script" +export reproducible_paper_group_name="$1" +sg "$1" "umask u+r,u+w,g+r,g+w,o-r,o-w,o-x && $script" -- cgit v1.2.1