Browse Source

add option to include stderr when recalling output

Daniel Sheffield 3 months ago
parent
commit
2096302edc
1 changed files with 6 additions and 6 deletions
  1. 6 6
      recall.sh

+ 6 - 6
recall.sh

@@ -17,6 +17,7 @@ stderr_deps=/dev/null
 #stderr_deps='/proc/self/fd/2'
 check_deps 3>&2 2>"$stderr_deps" 1>/dev/null
 
+INCLUDE_STDERR=false
 EXIT_SUCCESS=false
 LIST_MODE=false
 CMD_STRING=false
@@ -61,9 +62,12 @@ the captured exit status.
 EOF
 }
 
-OPTSTRING=":zhln:s0"
+OPTSTRING=":ehln:sz0"
 parse_opt () {
 	case "${opt}" in
+		e)
+			INCLUDE_STDERR=true
+		;;
 		h)
 			usage
 			exit 0
@@ -210,11 +214,7 @@ else
 	# shellcheck disable=SC1090
 	. <(tail -n +2 "$INF") # first line is commandline
 	"$EXIT_SUCCESS" && status=0
-	#TODO: allow user to request stderr in case it is needed for
-	#      testing redirections
-	#      disabled by defualt as it won't be interleaved correctly
-	#      on the console
-	false && cat "$ERR" >&2
+	"$INCLUDE_STDERR" && cat "$ERR" >&2
 	cat "$OUT"
 	exit "$status"
 fi