Move the source file descriptor SRCFD to the destination file descriptor DSTFD. The source file descriptor is closed.
If the predefined options --test or --show-program are enabled: print a line on the standard error channel describing the operation. If the predefined option --test is enabled: the file descriptor is still moved. Predefined options.
Let’s see how we can use a file for reading and writing with two moved file descriptors:
declare TESTFILE=/path/to/file.ext declare INFD=3 OUFD=4 DUP_INFD=5 DUP_OUFD=6 declare LINE mbfl_location_enter { mbfl_fd_open_input_output $INFD "$TESTFILE" mbfl_fd_open_output $OUFD "$TESTFILE" mbfl_fd_move $INFD $DUP_INFD mbfl_location_handler "mbfl_fd_close ${DUP_INFD}" mbfl_fd_move $OUFD $DUP_OUFD mbfl_location_handler "mbfl_fd_close ${DUP_OUFD}" echo 1234 >&${DUP_OUFD} read -u ${DUP_INFD} LINE } mbfl_location_leave echo LINE="$LINE"
This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.