summaryrefslogtreecommitdiffstats
path: root/src/fd.sh
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-01-17 16:10:31 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-01-17 16:10:31 (EST)
commit09c583248e7c0aa5a833ec01262b8b4a7980234b (patch)
treee3ecd4028e888d6eb587d9703ace4d90396a624a /src/fd.sh
parentd5e46c35ea98e43b6ad380ac7fbc197b7881b220 (diff)
parente3ab87a78aafd979f6eb8bb75ef70304d87a1d6b (diff)
Merge branch 'feature/improve-error-handling'
Diffstat (limited to 'src/fd.sh')
-rw-r--r--src/fd.sh10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/fd.sh b/src/fd.sh
index 0d5a50e..c52efec 100644
--- a/src/fd.sh
+++ b/src/fd.sh
@@ -63,8 +63,8 @@ fopen()
i=$(($i + 1))
done
if [ "x${fd:+set}" != 'xset' ]; then
- error 2 "$(get_msg 'emfile')"
- return
+ error "$(get_msg 'emfile')"
+ return 1
fi
if eval "exec ${fd}${mode}'${path}'"; then
@@ -72,7 +72,8 @@ fopen()
FD="${fd}"
return 0
else
- error 2 "$(get_msg 'cant_fopen')"
+ error "$(get_msg 'cant_fopen')"
+ return 1
fi
}
@@ -82,7 +83,8 @@ fclose()
# Make sure the file descriptor is open.
if [ "x$(eval echo "\${_fd_${fd}+set}")" != 'xset' ]; then
- error 2 "$(get_msg 'ebadf')"
+ error "$(get_msg 'ebadf')"
+ return 1
fi
eval "exec ${fd}>&-"