Bash can help allocate unused FD, so avoid hardcoding FD.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdumpctl | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 62c06bfb..048404b1 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -661,11 +661,10 @@ load_kdump()
ddebug "$KEXEC $KEXEC_ARGS $standard_kexec_args --command-line=$KDUMP_COMMANDLINE
--initrd=$TARGET_INITRD $KDUMP_KERNEL"
- # The '12' represents an intermediate temporary file descriptor
- # to store the standard error file descriptor '2', and later
- # restore the error file descriptor with the file descriptor '12'
- # and release it.
- exec 12>&2
+ # Use an temporary file descriptor to store the standard error
+ # file descriptor '2', and later restore the error file descriptor
+ local temp_fd
+ exec {temp_fd}>&2
exec 2>> $KDUMP_LOG_PATH/kdump.log
PS4='+ $(date "+%Y-%m-%d %H:%M:%S") ${BASH_SOURCE}@${LINENO}: '
set -x
@@ -677,7 +676,7 @@ load_kdump()
ret=$?
set +x
- exec 2>&12 12>&-
+ eval "exec 2>&$temp_fd $temp_fd>&-"
remove_kdump_kernel_key
--
2.31.1