diff --git a/command/eval.sh b/command/eval.sh index d683c5fd..64b65fb8 100644 --- a/command/eval.sh +++ b/command/eval.sh @@ -110,7 +110,7 @@ _Dbg_do_eval() { typeset -i _Dbg_rc if [[ -t $_Dbg_fdi ]] ; then _Dbg_set_dol_q $_Dbg_debugged_exit_code - . $_Dbg_evalfile >&${_Dbg_fdi} + . $_Dbg_evalfile >>"$_Dbg_tty" else _Dbg_set_dol_q $_Dbg_debugged_exit_code . $_Dbg_evalfile diff --git a/lib/msg.sh b/lib/msg.sh index 8f9bc153..53b90468 100644 --- a/lib/msg.sh +++ b/lib/msg.sh @@ -41,7 +41,7 @@ _Dbg_confirm() { if [[ -t $_Dbg_fdi ]]; then vared -e -h -p "$_Dbg_confirm_prompt" _Dbg_response <&${_Dbg_fdi} || break else - read "?$_Dbg_confirm_prompt" _Dbg_response <&${_Dbg_fdi} || break + read "?$_Dbg_confirm_prompt" _Dbg_response <&${_Dbg_fdi} >>$_Dbg_prompt_output || break fi case "$_Dbg_response" in @@ -86,8 +86,9 @@ function _Dbg_errmsg_no_cr { } function _Dbg_msg { - if [[ -n $_Dbg_fdi ]] && [[ -t $_Dbg_fdi ]] ; then - builtin print -- "$@" >&${_Dbg_fdi} + #if [[ -n "$_Dbg_tty" ]] && [[ -t "$_Dbg_tty" ]] ; then + if [[ -n "$_Dbg_tty" ]] ; then + builtin print -- "$@" >> "$_Dbg_tty" else builtin print -- "$@" fi @@ -95,8 +96,9 @@ function _Dbg_msg { } function _Dbg_msg_nocr { - if [[ -n $_Dbg_fdi ]] && [[ -t $_Dbg_fdi ]] ; then - builtin echo -n "$@" >&${_Dbg_fdi} + #if [[ -n "$_Dbg_tty" ]] && [[ -t "$_Dbg_tty" ]] ; then + if [[ -n "$_Dbg_tty" ]] ; then + builtin echo -n "$@" >>"$_Dbg_tty" else builtin echo -n "$@" fi @@ -117,8 +119,9 @@ function _Dbg_printf_nocr { builtin printf "$format" "$@" >>$_Dbg_logfid fi if (( ! _Dbg_logging_redirect )) ; then - if [[ -n $_Dbg_fdi ]] && [[ -t $_Dbg_fdi ]] ; then - builtin printf "$format" "$@" >&${_Dbg_fdi} + #if [[ -n $_Dbg_fdi ]] && [[ -t $_Dbg_fdi ]] ; then + if [[ -n "$_Dbg_tty" ]] ; then + builtin printf "$format" "$@" >>"$_Dbg_tty" else builtin printf "$format" "$@" fi diff --git a/lib/processor.sh b/lib/processor.sh index abdeac29..98ca6337 100644 --- a/lib/processor.sh +++ b/lib/processor.sh @@ -84,6 +84,7 @@ function _Dbg_process_commands { ${hook} done + _Dbg_prompt_output="${_Dbg_tty:-/dev/null}" # Loop over all pending open input file descriptors while (( ${#_Dbg_fd[@]} > 0 )) ; do @@ -124,21 +125,21 @@ function _Dbg_process_commands { ((_Dbg_cmd_num++)) if ((0 == _Dbg_in_vared)) && [[ -t $_Dbg_fdi ]]; then _Dbg_in_vared=1 - vared -e -h -p "$_Dbg_prompt" line <&${_Dbg_fdi} || break + vared -e -h -p "$_Dbg_prompt" line 2>>$_Dbg_prompt_output <&${_Dbg_fdi} || break _Dbg_in_vared=0 else if ((1 == _Dbg_in_vared)) ; then - _Dbg_msg "Unable to echo characters in input below" + _Dbg_msg "Unable to echo characters in input below" fi if [[ -z ${_Dbg_cmdfile[-1]} ]] ; then - read -u ${_Dbg_fdi} "?$_Dbg_prompt" line || break + read -u ${_Dbg_fdi} "?$_Dbg_prompt" line 2>>$_Dbg_prompt_output || break else - read -u ${_Dbg_fdi} line || break + read -u ${_Dbg_fdi} line || break fi fi - _Dbg_onecmd "$line" - rc=$? - _Dbg_postcmd + _Dbg_onecmd "$line" + rc=$? + _Dbg_postcmd ((_Dbg_continue_rc >= 0)) && return $_Dbg_continue_rc # Add $line to the debugger history file unless there was an @@ -156,7 +157,7 @@ function _Dbg_process_commands { fi fi - (( rc > 0 )) && return $rc + (( rc > 0 )) && return $rc line='' done # read "?$_Dbg_prompt" ... @@ -207,8 +208,8 @@ _Dbg_onecmd() { fi if [[ -n ${_Dbg_debugger_commands[$expanded_alias]} ]] ; then - ${_Dbg_debugger_commands[$expanded_alias]} $args - return $? + ${_Dbg_debugger_commands[$expanded_alias]} $args + return $? fi # The below are command names that are just a little irregular @@ -254,7 +255,7 @@ _Dbg_onecmd() { * ) if (( _Dbg_set_autoeval )) ; then if [[ -t $_Dbg_fdi ]] ; then - if ! _Dbg_do_eval $_Dbg_cmd $args >&${_Dbg_fdi} 2>&1 ; then + if ! _Dbg_do_eval $_Dbg_cmd $args >>"$_Dbg_tty" 2>&1 ; then return -1 fi else diff --git a/lib/tty.sh b/lib/tty.sh index 41b372c8..bdfa444d 100644 --- a/lib/tty.sh +++ b/lib/tty.sh @@ -30,11 +30,11 @@ function _Dbg_open_if_tty { _Dbg_new_fd=-1 (( $# != 1 )) && return 1 - [[ ! -r $1 ]] || [[ ! -w $1 ]] && return 1 + [[ ! -w $1 ]] && return 1 typeset -i r=1 # Code modelled off of code from David Korn: { - if exec {_Dbg_new_fd} <> $1 ; then + if exec ${_Dbg_new_fd} > $1 ; then if [[ -t $_Dbg_new_fd ]] ; then r=0 else