I am using ksh88 and I am trying to catch the return status of opening a file using a file descriptor and the exec and eval commands. However I am not having much success. Here is what I have:
eval "exec $next_fh>$1"
This opens the file if the file is $1 is valid, however I want to make sure it is valid. I tried:
command eval "exec $next_fh>$1" || print -u2 "Unable to open log file: $1"; return 1
This works, but I return the $next_fh value to the calling script and for some reason it does not execute the print above but it is evaluated and returned to the calling script and I get a bad file descriptor.
Any help would be appreciated. Thanks.