X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/d8708eb1722b30fd0e6c1ac1bf909f127a8fa040..f694b9e909dadbf02043000bc4c169891f0b8000:/unitproc/bktemp-setTimeZoneEV diff --git a/unitproc/bktemp-setTimeZoneEV b/unitproc/bktemp-setTimeZoneEV index 6933752..0855c1e 100644 --- a/unitproc/bktemp-setTimeZoneEV +++ b/unitproc/bktemp-setTimeZoneEV @@ -8,15 +8,18 @@ try() { "$@" || die "cannot $*"; } setTimeZoneEV(){ # Desc: Set time zone environment variable TZ # Usage: setTimeZoneEV arg1 + # Version 0.1.2 # Input: arg1: 'date'-compatible timezone string (ex: "America/New_York") # TZDIR env var (optional; default: "/usr/share/zoneinfo") # Output: exports TZ # exit code 0 on success # exit code 1 on incorrect number of arguments # exit code 2 if unable to validate arg1 - # Depends: yell, die, try - ARG1="$1" - local tzDir returnState + # Depends: yell(), printenv 8.30, bash 5.0.3 + # Tested on: Debian 10 + local tzDir returnState argTimeZone + + argTimeZone="$1" if ! [[ $# -eq 1 ]]; then yell "ERROR:Invalid argument count."; return 1; @@ -30,12 +33,12 @@ setTimeZoneEV(){ fi # Validate TZ string - if ! [[ -f "$tzDir"/"$ARG1" ]]; then + if ! [[ -f "$tzDir"/"$argTimeZone" ]]; then yell "ERROR:Invalid time zone argument."; return 2; else # Export ARG1 as TZ environment variable - TZ="$ARG1" && export TZ && returnState="true"; + TZ="$argTimeZone" && export TZ && returnState="true"; fi # Determine function return code @@ -66,6 +69,8 @@ date --iso-8601=seconds cmd4="setTimeZoneEV Pacific/Lemuria" echo "Running:$cmd4"; $cmd4; echo "Exit code:$?" date --iso-8601=seconds; echo "==============="; sleep 2 + +try setTimeZoneEV Atlantic/Atlantis #==END sample code== # Author: Steven Baltakatei Sandoval