diff options
-rw-r--r-- | src/fd.sh | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -57,7 +57,8 @@ fopen() # Find first available file descriptor. i=${_FD_MIN} while [ ${i} -le ${_FD_MAX} ]; do - if [ "x$(eval echo "\${_fd_${i}+set}")" != 'xset' ]; then + if [ "x$(eval "printf '%s' \"\${_fd_${i}+set}\"")" != 'xset' ] + then fd=${i} break fi @@ -68,8 +69,8 @@ fopen() return 1 fi - if eval "exec ${fd}${mode}'${path}'"; then - eval "_fd_${fd}='${mode}${path}'" + if eval "exec ${fd}${mode}\"\${path}\""; then + eval "_fd_${fd}=\"\${mode}\${path}\"" FD="${fd}" return 0 else @@ -84,7 +85,7 @@ fclose() shift 1 # Make sure the file descriptor is open. - if [ "x$(eval echo "\${_fd_${fd}+set}")" != 'xset' ]; then + if [ "x$(eval "printf '%s' \"\${_fd_${fd}+set}\"")" != 'xset' ]; then error "$(get_msg 'ebadf')" return 1 fi |