#!/usr/bin/env bash # Purpose: Check data file against DIWG (and, eventually, other) recommendations # Copyright (C) 2023--present Charlie Zender, ... (Contribuing DIWG members---Add your names!) # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the 3-Clause BSD License for more details. # Prerequisites: Bash, NCO # Script could use other shells, e.g., dash (Debian default) after rewriting function definitions and loops # Debug with 'bash -x ncchecker --dbg=dbg_lvl' where 0 <= dbg_lvl <= 5 # Insta-install: # scp ~/diwg/ncchecker dust.ess.uci.edu:bin # scp dust.ess.uci.edu:bin/ncchecker ${MY_BIN_DIR} # Set script name, directory, PID, run directory drc_pwd=${PWD} # Security: Explicitly unset IFS before wordsplitting, so Bash uses default IFS= unset IFS # Set these before 'module' command which can overwrite ${BASH_SOURCE[0]} # NB: dash supports $0 syntax, not ${BASH_SOURCE[0]} syntax # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in spt_src="${BASH_SOURCE[0]}" [[ -z "${spt_src}" ]] && spt_src="${0}" # Use ${0} when BASH_SOURCE is unavailable (e.g., dash) while [ -h "${spt_src}" ]; do # Recursively resolve ${spt_src} until file is no longer a symlink drc_spt="$( cd -P "$( dirname "${spt_src}" )" && pwd )" spt_src="$(readlink "${spt_src}")" [[ ${spt_src} != /* ]] && spt_src="${drc_spt}/${spt_src}" # If ${spt_src} was relative symlink, resolve it relative to path where symlink file was located done cmd_ln="${spt_src} ${@}" drc_spt="$( cd -P "$( dirname "${spt_src}" )" && pwd )" spt_nm=$(basename ${spt_src}) # [sng] Script name (unlike $0, ${BASH_SOURCE[0]} works well with 'source