This file is indexed.

/usr/share/zshdb/command/eval.sh is in zshdb 0.92-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# -*- shell-script -*-
# Eval and Print commands.
#
#   Copyright (C) 2008, 2010-2011, 2014-2015 Rocky Bernstein
#   <rocky@gnu.org>
#
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License as
#   published by the Free Software Foundation; either version 2, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; see the file COPYING.  If not, write to
#   the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
#   MA 02111 USA.

# temp file for internal eval'd commands
typeset _Dbg_evalfile=$(_Dbg_tempname eval)

# _Dbg_complete_level_1_data[eval?]=\
#   '\$(typeset extracted; \
#     _Dbg_eval_extract_condition "$_Dbg_source_line"; echo $extracted)'

_Dbg_complete_eval() {
    echo $ZSH_DEBUG_CMD
}

_Dbg_complete_level_1_data[eval]='-Q_Dbg_complete_eval'

_Dbg_help_add eval \
'**eval** *cmd*

**eval**

**eval?**

In the first form *cmd* is a string *cmd* is a string sent to special
shell builtin eval.

In the second form, use evaluate the current source line text.

Often when one is stopped at the line of the first part of an "if",
"elif", "case", "return", "while" compound statement or an assignment
statement, one wants to eval is just the expression portion.  For
this, use eval?. Actually, any alias that ends in ? which is aliased
to eval will do thie same thing.

See also:
---------

**print** and **set autoeval**.'

typeset -i _Dbg_show_eval_rc; _Dbg_show_eval_rc=1

_Dbg_do_eval() {

    print ". ${_Dbg_libdir}/lib/set-d-vars.sh" > $_Dbg_evalfile
    if (( $# == 0 )) ; then
        # FIXME: add parameter to get unhighlighted line, or
        # always save a copy of that in _Dbg_sget_source_line
        typeset source_line
        typeset highlight_save=$_Dbg_set_highlight
        _Dbg_set_highlight=''
        _Dbg_get_source_line
        typeset source_line_save="$source_line"

        # Were we called via ? as the suffix?
        typeset suffix
        suffix=${_Dbg_orig_cmd[-1,-1]}

        # ZSH_DEBUG_CMD is preferable to _Dbg_source_line in that we
        # know is a complete statement. But to determine if it is a
        # compound statement like "if .. ; then .. fi we'd prefer just
        # to go with the line shown and pehraps use eval? to shorten
        # that.  The heuristic we use to determine a compound statement
        # is just whether the the length of text of the the current is less
        # than the length of the full command in ZSH_DEBUG_CMD
        if (( ${#source_line} > ${#ZSH_DEBUG_CMD} )) ; then
            source_line=$ZSH_DEBUG_CMD
        fi
        if [[ '?' == "$suffix" ]] ; then
            typeset extracted
            _Dbg_eval_extract_condition "$source_line"
            source_line="$extracted"
            source_line_save="$extracted"
        fi

        print "$source_line" >> $_Dbg_evalfile
        _Dbg_msg "eval: ${source_line}"
        _Dbg_source_line="$source_line_save"
        _Dbg_set_highlight=$_Dbg_highlight_save
    else
        print "$@" >> $_Dbg_evalfile
    fi
    print '_Dbg_rc=$?' >> $_Dbg_evalfile
    typeset -i _Dbg_rc
    if [[ -t $_Dbg_fdi  ]] ; then
        _Dbg_set_dol_q $_Dbg_debugged_exit_code
        . $_Dbg_evalfile >&${_Dbg_fdi}
    else
        _Dbg_set_dol_q $_Dbg_debugged_exit_code
        . $_Dbg_evalfile
    fi
    (( _Dbg_show_eval_rc )) && _Dbg_msg "\$? is $_Dbg_rc"
    # We've reset some variables like IFS and PS4 to make eval look
    # like they were before debugger entry - so reset them now.
    _Dbg_set_debugger_internal
    _Dbg_last_cmd='eval'
    return 0
}

_Dbg_alias_add 'eval?' 'eval'
_Dbg_alias_add 'ev' 'eval'
_Dbg_alias_add 'ev?' 'eval'

# The arguments in the last "print" command.
typeset _Dbg_last_print_args=''

_Dbg_help_add print \
'print EXPRESSION -- Print EXPRESSION.

EXPRESSION is a string like you would put in a print statement.
See also eval.

The difference between eval and print. Suppose cmd has the value "ls".

print $cmd # prints "ls"
eval $cmd  # runs an ls command
'

_Dbg_do_print() {
    typeset _Dbg_expr; _Dbg_expr=${@:-"$_Dbg_last_print_args"}
    typeset dq_expr; dq_expr=$(_Dbg_esc_dq "$_Dbg_expr")
    typeset -i _Dbg_show_eval_rc=0
    _Dbg_do_eval _Dbg_msg "$_Dbg_expr"
    typeset -i rc=$?
    _Dbg_last_print_args="$dq_expr"
    return 0
    # return $rc
}

_Dbg_alias_add 'pr' 'print'