File: run.sh

package info (click to toggle)
zshdb 0.04%2Bgit20100102-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,924 kB
  • ctags: 241
  • sloc: sh: 5,097; lisp: 885; makefile: 306
file content (79 lines) | stat: -rw-r--r-- 2,527 bytes parent folder | download
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
# -*- shell-script -*-
# run command.
#
#   Copyright (C) 2008, 2009 Rocky Bernstein  rocky@gnu.org
#
#   zshdb 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.
#
#   zshdb 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 zshdb; see the file COPYING.  If not, write to the Free Software
#   Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.

# Restart script in same way with saved arguments (probably the same
# ones as we were given before).

_Dbg_help_add run \
'run [args] -- Attempt to restart the program.'

_Dbg_do_run() {

  typeset script_args
  typeset exec_cmd
  if (( $# == 0 )) ; then 
      script_args=${_Dbg_script_args[@]}
      typeset SH_RUN_CMDLINE; _Dbg_run_cmdline
      if [[ -n $SH_RUN_CMDLINE ]] ; then
	  exec_cmd="$SH_RUN_CMDLINE";
      else
	  exec_cmd="$_Dbg_script_file"
	  [[ -n $script_args ]] && exec_cmd+=" $script_args"
      fi
  else
      exec_cmd="$_Dbg_script_file"
      script_args=$@
      [[ -n $script_args ]] && exec_cmd+=" $script_args"
  fi

  if (( !_Dbg_script )); then
#     if [[ $_cur_source_file == $_Dbg_bogus_file ]] ; then
#       script_args="--debugger -c \"$SH_EXECUTION_STRING\""
#       exec_cmd="$SH_RUN_CMDLINE --debugger -c \"$SH_EXECUTION_STRING\"";
#     else
#       exec_cmd="$SH_RUN_CMDLINE --debugger $_Dbg_orig_0 $script_args";
#     fi
      :
  fi

  if (( _Dbg_basename_only )) ; then 
    _Dbg_msg "Restarting with: $script_args"
  else
    _Dbg_msg "Restarting with: $exec_cmd"
  fi

  # If we are in a subshell we need to get out of those levels
  # first before we restart. The strategy is to write into persistent
  # storage the restart command, and issue a "quit." The quit should
  # discover the restart at the last minute and issue the restart.
  if (( ZSH_SUBSHELL > 0 )) ; then 
    _Dbg_msg "Note you are in a subshell. We will need to leave that first."
    _Dbg_write_journal "_Dbg_RESTART_COMMAND=\"$exec_cmd\""
    _Dbg_do_quit 0
  fi
  _Dbg_save_state

  builtin cd $_Dbg_init_cwd

  _Dbg_cleanup
  eval "exec $exec_cmd"
}

_Dbg_alias_add R run
_Dbg_alias_add restart run