debug(bklog):Fix version appending; test filewrite change
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Sat, 11 Jul 2020 07:33:28 +0000 (07:33 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Sat, 11 Jul 2020 07:33:28 +0000 (07:33 +0000)
exec/bklog

index 45d0bd7c26e68d05cc91d5baba9038c7961374bc..ecc31d854757bac08929be5af90d211cf532a97b 100644 (file)
@@ -11,7 +11,7 @@ dirTmpDefault="/dev/shm"; # Default parent of working directory
 
 # Script Metadata
 scriptName="bklog";             # Define basename of script file.
-scriptVersion="0.1.18";          # Define version of script.
+scriptVersion="0.1.19";          # Define version of script.
 scriptURL="https://gitlab.com/baltakatei/ninfacyzga-01"; # Define wesite hosting this script.
 scriptTimeStart="$(date +%Y%m%dT%H%M%S.%N)"; # YYYYmmddTHHMMSS.NNNNNNNNN
 scriptHostname=$(hostname);     # Save hostname of system running this script.
@@ -787,7 +787,7 @@ magicInitCheckTar() {
     # input: vars: scriptHostname
     # output: vars: pathout_tar
     # depends: Bash 5.0.3, vbm(), dateShort(), checkMakeTar(), magicWriteVersion()
-    local fn
+    local fn checkMakeTarES
 
     # Save function name
     fn="${FUNCNAME[0]}";    
@@ -797,10 +797,10 @@ magicInitCheckTar() {
     pathout_tar="$dirOut"/"$(dateShort "$(date --date="$bufferTTL seconds ago" --iso-8601=seconds)")".."$scriptHostname""$label""$cmd_compress_suffix""$cmd_encrypt_suffix".tar && \
        vbm "STATUS:$fn:Set pathout_tar to:$pathout_tar";
     # Validate pathout_tar as tar.
-    checkMakeTar "$pathout_tar";
+    checkMakeTar "$pathout_tar"; checkMakeTarES="$?";
     ## Add VERSION file if checkMakeTar had to create a tar (exited 1) or replace one (exited 2)
-    vbm "STATUS:$fn:exit status before magicWriteVersion:$?"
-    if [[ $? -eq 1 ]] || [[ $? -eq 2 ]]; then magicWriteVersion; fi
+    vbm "STATUS:$fn:exit status before magicWriteVersion:$checkMakeTarES"
+    if [[ "$checkMakeTarES" -eq 1 ]] || [[ "$checkMakeTarES" -eq 2 ]]; then magicWriteVersion; fi
     vbm "STATUS:$fn:Finished magicInitCheckTar() function.";
 } # Initialize tar, set pathout_tar
 magicParseCompressionArg() {
@@ -1203,7 +1203,7 @@ magicProcessWriteBuffer() {
     for index in "${!pathouts[@]}"; do
        writeCmd2="${procStrings[$index]}";
        writeCmdAll="$writeCmd1 | $writeCmd2 | $writeCmd3 | $writeCmd4" && vbm "STATUS:$fn:Assembled command:\"$writeCmdAll\"";
-       eval "$writeCmd1 | $writeCmd2 | $writeCmd3 | $writeCmd4" >> "${pathouts[$index]}" && vbm "STATUS:$fn:Wrote command output to ${pathouts[$index]}";
+       eval "$writeCmd1 | $writeCmd2 | $writeCmd3 | $writeCmd4" > "${pathouts[$index]}" && vbm "STATUS:$fn:Wrote command output to ${pathouts[$index]}";
     done;
     
     # Append dir_tmp files to pathout_tar
@@ -1331,7 +1331,9 @@ main() {
     ## Init temp working dir
     try mkdir "$dir_tmp" && vbm "DEBUG :$fn:Working dir created at dir_tmp:$dir_tmp";
     ## Initialize output tar (set pathout_tar)
-    magicInitCheckTar; 
+    magicInitCheckTar;
+    ## Append VERSION file to tar
+    magicWriteVersion;
     
     # Check vital apps, files, dirs
     if ! checkapp tar && ! checkdir "$dirOut" "dir_tmp"; then