Don't use working directory when --output-directory option is used
authorMichael Prokop <mika@grml.org>
Thu, 19 Nov 2015 14:47:07 +0000 (15:47 +0100)
committerMichael Prokop <mika@grml.org>
Thu, 19 Nov 2015 14:48:48 +0000 (15:48 +0100)
Otherwise when running something like:

  /root/system-info/grml-hwinfo --output-directory=/root/system-info/grml-hwinfo-data

via cron this store data to /root/root/system-info/grml-hwinfo-data
(instead of the requested /root/system-info/grml-hwinfo-data) since
/root is the working directory for cron.

grml-hwinfo

index 48b9676..75567b2 100755 (executable)
@@ -112,7 +112,12 @@ fi
 
 # Generate output/temporary directory name & path, and output file path
 [ -n "$OUTDIRNAME" ] || OUTDIRNAME="grml-hwinfo-${DATE}"
-OUTDIR="${WORKING_DIR}/${OUTDIRNAME}"
+if $_opt_output_directory ; then
+  OUTDIR="${OUTDIRNAME}"
+else
+  OUTDIR="${WORKING_DIR}/${OUTDIRNAME}"
+fi
+
 if $_opt_force ; then
   mkdir -p "${OUTDIR}"
 else