This file is indexed.

/usr/bin/sage is in sagemath-common 7.4-9.

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

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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
#!/usr/bin/env bash

help_banner() {
    sage_banner | grep -v 'Type'
    echo
}

usage() {
    help_banner
    ####  1.......................26..................................................78
    ####  |.....................--.|...................................................|
    echo "Optional arguments:"
    echo "  file.[sage|py|spyx] -- run given .sage, .py or .spyx file"
    echo "  -advanced           -- list all command line options"
    echo "  -c <cmd>            -- Evaluates cmd as sage code"
    echo "  -gap [...]          -- run Sage's Gap with given arguments"
    echo "  -gp [...]           -- run Sage's PARI/GP calculator with given arguments"
    echo "  -h, -?              -- print this help message"
    echo "  -inotebook [...]    -- start the *insecure* Sage notebook (deprecated)"
    echo "  -maxima [...]       -- run Sage's Maxima with given arguments"
    echo "  -mwrank [...]       -- run Sage's mwrank with given arguments"
    echo "  --notebook=[...]    -- start the Sage notebook (valid options are"
    echo "                         'default', 'sagenb', 'jupyter', and 'export')"
    echo "  -n, --notebook      -- shortcut for --notebook=default"
    echo "  -python [...]       -- run the Python interpreter"
    echo "  -R [...]            -- run Sage's R with given arguments"
    echo "  -singular [...]     -- run Sage's singular with given arguments"
    echo "  -sqlite3 [...]      -- run Sage's sqlite3 with given arguments"
    echo "  -root               -- print the Sage root directory"
    echo "  --nodotsage         -- run Sage without using the user's .sage directory:"
    echo "                         create and use a temporary .sage directory instead"
    echo "  -t [options] <--all|files|dir>"
    echo "                      -- test examples in .py, .pyx, .sage, .tex or .rst files"
    echo "                         selected options:"
    echo "                           --long - include lines with the phrase 'long time'"
    echo "                           --verbose - print debugging output during the test"
    echo "                           --optional - controls which optional tests are run"
    echo "                           --sagenb - test all sagenb files"
    echo "                           --help - show all testing options"
    echo "  -v, -version        -- display Sage version information"
    exit 0
}

usage_advanced() {
    help_banner
    ####  1.......................26..................................................78
    ####  |.....................--.|...................................................|
    echo "Running Sage:"
    echo "  file.[sage|py|spyx] -- run given .sage, .py or .spyx file"
    echo "  -advanced           -- print this advanced help message"
    echo "  -c <cmd>            -- Evaluates cmd as sage code"
    echo "  -h, -?              -- print short help message"
    echo "  -min [...]          -- do not populate global namespace (must be first"
    echo "                         option)"
    echo "  -preparse <file.sage> -- preparse file.sage and produce corresponding file.sage.py"
    echo "  -q                  -- quiet; start with no banner"
    echo "  -root               -- print the Sage root directory"
    echo "  -gthread, -qthread, -q4thread, -wthread, -pylab"
    echo "                      -- pass the option through to ipython"
    echo "  -v, -version        -- display Sage version information"
    echo "  -dumpversion        -- print Sage version"

    echo
    ####  1.......................26..................................................78
    ####  |.....................--.|...................................................|
    echo "Running the notebook:"
    echo "  --notebook=[...]    -- start the Sage notebook (valid options are"
    echo "                         'default', 'sagenb', and 'jupyter'). See the output"
    echo "                         of sage --notebook --help for more details and"
    echo "                         examples of how to pass optional arguments"
    echo "  -inotebook [...]    -- start the *insecure* Sage notebook (deprecated)"
    echo "  -n, -notebook [...] -- start the default Sage notebook (options are the"
    echo "                         same as for the notebook command in Sage).  See the"
    echo "                         output of sage -n -h for more details"

    echo
    ####  1.......................26..................................................78
    ####  |.....................--.|...................................................|
    echo "Running external programs:"
    echo "  -cleaner            -- run the Sage cleaner"
    echo "  -cython [...]       -- run Cython with given arguments"
    echo "  -ecl [...]          -- run Common Lisp"
    echo "  -gap [...]          -- run Sage's Gap with given arguments"
    echo "  -gdb                -- run Sage under the control of gdb"
    echo "  -gp [...]           -- run Sage's PARI/GP calculator with given arguments"
    echo "  -ipython [...]      -- run Sage's IPython using the default environment (not"
    echo "                         Sage), passing additional options to IPython"
    echo "  -kash [...]         -- run Sage's Kash with given arguments"
    command -v kash &>/dev/null || \
    echo "                         (not installed currently, run sage -i kash)"
    echo "  -lisp [...]         -- run Lisp interpreter included with Sage"
    echo "  -M2 [...]           -- run Sage's Macaulay2 with given arguments"
    command -v M2 &>/dev/null || \
    echo "                         (not installed currently, run sage -i macaulay2)"
    echo "  -maxima [...]       -- run Sage's Maxima with given arguments"
    echo "  -mwrank [...]       -- run Sage's mwrank with given arguments"
    echo "  -polymake [...]     -- run Sage's Polymake with given arguments"
    command -v polymake &>/dev/null || \
    echo "                         (not installed currently, run sage -i polymake)"
    echo "  -python [...]       -- run the Python interpreter"
    echo "  -R [...]            -- run Sage's R with given arguments"
    echo "  -sh [...]           -- run \$SHELL ($SHELL) with Sage environment variables"
    echo "  -singular [...]     -- run Sage's singular with given arguments"
    echo "  -sqlite3 [...]      -- run Sage's sqlite3 with given arguments"
    echo "  -twistd [...]       -- run Twisted server"

    echo
    ####  1.......................26..................................................78
    ####  |.....................--.|...................................................|
    echo "Testing the Sage library:"
    echo "  -startuptime [module] -- display how long each component of Sage takes to"
    echo "                         start up; optionally specify a module to get more"
    echo "                         details about that particular module"
    echo "  -t [options] <--all|files|dir>"
    echo "                      -- test examples in .py, .pyx, .sage, .tex or .rst files"
    echo "                         selected options:"
    echo "                           --long - include lines with the phrase 'long time'"
    echo "                           --verbose - print debugging output during the test"
    echo "                           --randorder[=seed] - randomize order of tests"
    echo "                           --initial - only show the first failure per block"
    echo "                           --debug - drop into PDB after an unexpected error"
    echo "                           --failed - only test files that failed last test"
    echo "                           --sagenb - test all sagenb files"
    echo "                           --help - show all testing options"
    echo "                           --warn-long [timeout] - warning if doctest is slow"
    echo "  -tp <N> [...]       -- like -t above, but tests in parallel using N threads"
    echo "                         with 0 interpreted as a sensible default"
    echo "  -testall [options]  -- test all source files, docs, and examples.  options"
    echo "                         like -t"

    echo
    ####  1.......................26..................................................78
    ####  |.....................--.|...................................................|
    echo "Documentation:"
    echo "  -docbuild [lang/]<document> <html|pdf|...> -- Build the Sage documentation"
    echo "  -search_src <string> -- search through all the Sage library code for string"
    echo "  -search_doc <string> -- search through the Sage documentation for string"
    echo "  -grep <string>      -- same as -search_src"
    echo "  -grepdoc <string>   -- same as -search_doc"

    echo
    ####  1.......................26..................................................78
    ####  |.....................--.|...................................................|
    echo "File conversion:"
    echo "  -rst2txt [...]      -- Generates Sage worksheet text file from standalone"
    echo "                         reStructuredText source."
    echo "  -rst2sws [...]      -- Generates Sage worksheet (.sws) from standalone"
    echo "                         reStructuredText source."
    echo "  -sws2rst <sws doc>  -- Generates a reStructuredText source file from"
    echo "                         a Sage worksheet (.sws) document."

    echo
    ####  1.......................26..................................................78
    ####  |.....................--.|...................................................|
    echo "Valgrind memory debugging:"
    echo "  -cachegrind         -- run Sage using Valgrind's cachegrind tool.  The log"
    echo "                         files are named sage-cachegrind.PID can be found in"
    echo "                         $DOT_SAGE"
    echo "  -callgrind          -- run Sage using Valgrind's callgrind tool.  The log"
    echo "                         files are named sage-callgrind.PID can be found in"
    echo "                         $DOT_SAGE"
    echo "  -massif             -- run Sage using Valgrind's massif tool.  The log"
    echo "                         files are named sage-massif.PID can be found in"
    echo "                         $DOT_SAGE"
    echo "  -memcheck           -- run Sage using Valgrind's memcheck tool.  The log"
    echo "                         files are named sage-memcheck.PID can be found in"
    echo "                         $DOT_SAGE"
    echo "  -omega              -- run Sage using Valgrind's omega tool.  The log"
    echo "                         files are named sage-omega.PID can be found in"
    echo "                         $DOT_SAGE"
    echo "  -valgrind           -- this is an alias for -memcheck"
    echo
    echo "You can also use -- before a long option, e.g., 'sage --optional'."
    echo
    exit 0
}


#####################################################################
# Special options to be processed without sage-env
#####################################################################

# Check for '--nodotsage' before sourcing sage-env; otherwise sage-env
# will already have set some environment variables with the old
# setting for DOT_SAGE.
if [ "$1" = '--nodotsage' ]; then
    export DOT_SAGE=`mktemp -d ${TMPDIR:-/tmp}/dotsageXXXXXX`
    shift
    command "$0" "$@"
    status=$?
    rm -rf "$DOT_SAGE"
    exit $status
fi

#####################################################################
# Source sage-env ($0 is the name of this "sage" script, so we can just
# append -env to that). We redirect stdout to stderr, which is safer
# for scripts.
#####################################################################
if [ "\"$0\"" = "\"/usr/bin/sage\"" ]; then
    . "/usr/share/sagemath/bin/sage-env" >&2
else
    . "$0-env" >&2
fi

if [ $? -ne 0 ]; then
    echo >&2 "Error setting environment variables by sourcing '$0-env';"
    echo >&2 "possibly contact sage-devel (see http://groups.google.com/group/sage-devel)."
    exit 1
fi


if [ $# -gt 0 ]; then
  if [ "$1" = '-h' -o "$1" = '-?' -o "$1" = '-help' -o "$1" = '--help' ]; then
     usage
  fi
  if [ "$1" = "-advanced" -o "$1" = "--advanced" ]; then
     usage_advanced
  fi
fi

# Prepare for running Sage, either interactively or non-interactively.
sage_setup() {
    if [ "$SAGE_BANNER" != "no" ]; then
        cat "/usr/share/sagemath/bin/sage-banner"
    fi

    sage-cleaner &>/dev/null &
}

# Start an interactive Sage session, this function never returns.
interactive_sage() {
    sage_setup
    exec sage-ipython "$@" -i
}

if [ "$1" = '-min' -o "$1" = '--min' ]; then
    shift
    export SAGE_IMPORTALL=no
fi

if [ "$1" = '-q' ]; then
    shift
    export SAGE_BANNER=no
fi

if [ $# -eq 0 ]; then
    interactive_sage
fi

if [ "$1" = '-cleaner' -o "$1" = '--cleaner' ]; then
    exec sage-cleaner
fi

#####################################################################
# Report information about the Sage environment
#####################################################################

if [ "$1" = '-dumpversion' -o "$1" = '--dumpversion' ]; then
	. "$SAGE_SCRIPTS_DIR"/sage-version.sh
	echo ${SAGE_VERSION}
	exit 0
fi

if [ "$1" = '-v' -o "$1" = '-version' -o "$1" = '--version' ]; then
	. "$SAGE_SCRIPTS_DIR"/sage-version.sh
	echo "SageMath version ${SAGE_VERSION}, Release Date: ${SAGE_RELEASE_DATE}"
	exit 0
fi

if [ "$1" = '-root'  -o "$1" = '--root' ]; then
    echo "$SAGE_ROOT"
    exit 0
fi

#####################################################################
# Run Sage's versions of the standard Algebra/Geometry etc. software
#####################################################################

if [ "$1" = '-axiom' -o "$1" = '--axiom' ]; then
    shift
    exec axiom "$@"
fi

if [ "$1" = '-gap' -o "$1" = '--gap' ]; then
    shift
    exec gap "$@"
fi

if [ "$1" = '-gp' -o "$1" = '--gp' ]; then
    shift
    exec gp "$@"
fi

if [ "$1" = '-polymake' -o "$1" = '--polymake' ]; then
    shift
    exec polymake "$@"
fi

if [ "$1" = '-singular' -o "$1" = '--singular' ]; then
    shift
    exec Singular -t "$@"
fi

if [ "$1" = '-sqlite3' -o "$1" = '--sqlite3' ]; then
    shift
    exec sqlite3 "$@"
fi

if [ "$1" = '-sws2rst' -o "$1" = '--sws2rst' ]; then
    shift
    exec sage-sws2rst "$@"
fi

if [ "$1" = '-twistd' -o "$1" = '--twistd' ]; then
    shift
    exec twistd "$@"
fi

if [ "$1" = '-ecl' -o "$1" = '--ecl' ]; then
    shift
    exec ecl "$@"
fi

if [ "$1" = '-lisp' -o "$1" = '--lisp' ]; then
    shift
    exec ecl "$@"
fi

if [ "$1" = '-kash' -o "$1" = '--kash' ]; then
    shift
    exec kash "$@"
fi

if [ "$1" = '-maxima' -o "$1" = '--maxima' ]; then
    shift
    exec maxima-sage "$@"
fi

if [ "$1" = '-mwrank' -o "$1" = '--mwrank' ]; then
    shift
    exec mwrank "$@"
fi

if [ "$1" = '-M2' -o "$1" = '--M2' ]; then
    shift
    exec M2 "$@"
fi

if [ "$1" = '-python' -o "$1" = '--python' ]; then
    shift
    exec python "$@"
fi

if [ "$1" = '-R' -o "$1" = '--R' ]; then
    shift
    exec R "$@"
fi

if [ "$1" = '-ipython' -o "$1" = '--ipython' ]; then
    shift
    exec ipython "$@"
fi

if [ "$1" = '-git' -o "$1" = '--git' ]; then
    shift
    exec git "$@"
fi

if [ "$1" = '-sh' -o "$1" = '--sh' ]; then
    # AUTHORS:
    # - Carl Witty and William Stein: initial version
    # - Craig Citro: add options for not loading profile
    # - Martin Albrecht: fix zshell prompt (#11866)
    # - John Palmieri: shorten the prompts, and don't print messages if
    #   there are more arguments to 'sage -sh' (#11790)
    shift
    # If $SHELL is unset, default to bash
    if [ -z "$SHELL" ]; then
        export SHELL=bash
    fi
    # We must start a new shell with no .profile or .bashrc files
    # processed, so that we know our path is correct
    SHELL_NAME=`basename "$SHELL"`
    # Check for SAGE_SHPROMPT.  If defined, use for the prompt.  If
    # not, check for already-defined $PS1, and if defined use that.
    # $PS1 should only be available if it is defined in
    # $DOT_SAGE/sagerc.
    if [ -n "$SAGE_SHPROMPT" ]; then
        oldPS1=$SAGE_SHPROMPT
    elif [ -n "$PS1" ]; then
        oldPS1=$PS1
    fi
    # Set the default prompt.  If available, use reverse video to
    # highlight the string "(sage-sh)".
    if tput rev &>/dev/null; then
        color_prompt=yes
    fi
    case "$SHELL_NAME" in
        bash)
            SHELL_OPTS="--norc"
            if [ "$color_prompt" = yes ]; then
                PS1="\[$(tput rev)\](sage-sh)\[$(tput sgr0)\] \u@\h:\W\$ "
            else
                PS1="(sage-sh) \u@\h:\w\$ "
            fi
            export PS1
            ;;
        csh)
            # csh doesn't seem to allow the specification of a different
            # .cshrc file, and the prompt can only be set in this file, so
            # don't bother changing the prompt.
            SHELL_OPTS="-f"
            ;;
        ksh)
            SHELL_OPTS="-p"
            if [ "$color_prompt" = yes ] ; then
                PS1="$(tput rev)(sage-sh)$(tput sgr0) $USER@`hostname -s`:\${PWD##*/}$ "
            else
                PS1="(sage-sh) $USER@`hostname -s`:\${PWD##*/}$ "
            fi
            export PS1
            ;;
        sh)
            # We don't really know which shell "sh" is (it could be
            # bash, but this is not guaranteed), so we don't set
            # SHELL_OPTS.
            if [ "$color_prompt" = yes ] ; then
                PS1="$(tput rev)(sage-sh)$(tput sgr0) $USER@`hostname -s`:\${PWD##*/}$ "
            else
                PS1="(sage-sh) $USER@`hostname -s`:\${PWD}$ "
            fi
            export PS1
            ;;
        tcsh)
            # tcsh doesn't seem to allow the specification of a different
            # .tcshrc file, and the prompt can only be set in this file, so
            # don't bother changing the prompt.
            SHELL_OPTS="-f"
            ;;
        zsh)
            PS1="%S(sage-sh)%s %n@%m:%~$ "
            # In zsh, the system /etc/zshenv is *always* run,
            # and this may change the path (like on OSX), so we'll
            # create a temporary .zshenv to reset the path
            ZDOTDIR=$DOT_SAGE && export ZDOTDIR
            cat >"$ZDOTDIR/.zshenv" <<EOF
PATH="$PATH" && export PATH
EOF
            SHELL_OPTS=" -d"
            export PS1
            ;;
        *)
            export PS1='(sage-sh) $ '
            ;;
    esac
    if [ -n "$oldPS1" ]; then
        PS1="$oldPS1"
        export PS1
    fi
    if [ $# -eq 0 ]; then
        # No arguments, so print informative message...
        echo >&2
        echo >&2 "Starting subshell with Sage environment variables set.  Don't forget"
        echo >&2 "to exit when you are done.  Beware:"
        echo >&2 " * Do not do anything with other copies of Sage on your system."
        echo >&2 " * Do not use this for installing Sage packages using \"sage -i\" or for"
        echo >&2 "   running \"make\" at Sage's root directory.  These should be done"
        echo >&2 "   outside the Sage shell."
        echo >&2
        if [ -n "$SHELL_OPTS" ]; then
            echo >&2 "Bypassing shell configuration files..."
            echo >&2
        fi
        echo >&2 "Note: SAGE_ROOT=$SAGE_ROOT"
        "$SHELL" $SHELL_OPTS "$@"
        status=$?
        echo "Exited Sage subshell." 1>&2
    else
        exec "$SHELL" $SHELL_OPTS "$@"
        # If 'exec' returns, an error occurred:
        status=$?
        echo >&2 "Fatal error: 'exec \"$SHELL\" \"$@\"' failed!"
    fi
    exit $status
fi

#####################################################################
# File conversion
#####################################################################

if [ "$1" = '-rst2txt' -o "$1" = '--rst2txt' ]; then
    shift
    exec sage-rst2txt "$@"
fi

if [ "$1" = '-rst2sws' -o "$1" = '--rst2sws' ]; then
    shift
    exec sage-rst2sws "$@"
fi

#####################################################################
# Run Sage's versions of the standard Algebra/Geometry etc. software
#####################################################################

if [[ "$1" =~ ^--notebook=.* || "$1" =~ ^-n=.* || "$1" =~ ^-notebook=.* ]] ; then
    sage-cleaner &>/dev/null &
    exec sage-notebook "$@"
fi

if [ "$1" = "-notebook" -o "$1" = '--notebook' -o "$1" = '-n' ]; then
    sage-cleaner &>/dev/null &
    exec sage-notebook "$@"
fi

if [ "$1" = "-inotebook" -o "$1" = '--inotebook' ]; then
    shift
    sage-cleaner &>/dev/null &
    exec sage-notebook --notebook=sagenb secure=False "$@"
fi

if [ "$1" = '-grep' -o "$1" = "--grep" -o "$1" = "-search_src" -o "$1" = "--search_src" ]; then
   shift
   sage-grep "$@"
   exit 0
fi

if [ "$1" = '-grepdoc' -o "$1" = "--grepdoc" -o "$1" = "-search_doc" -o "$1" = "--search_doc" ]; then
   shift
   sage-grepdoc "$@"
   exit 0
fi

if [ "$1" = '-r' ]; then
   shift
   interactive_sage
fi

if [ "$1" = '-t' -o "$1" = '-tp' ]; then
    if [ ! -f  "$DOT_SAGE"/init.sage ]; then
        echo >&2 "init.sage does not exist ... creating"
        touch "$DOT_SAGE"/init.sage
    fi
    SAGE_BANNER=no sage_setup
    export PYTHONIOENCODING="utf-8"  # Fix encoding for doctests
    if [ "$1" = '-tp' ]; then
        shift
        exec sage-runtests -p "$@"
    else
        shift
        exec sage-runtests "$@"
    fi
fi

if [ "$1" = '-testall' -o "$1" = "--testall" ]; then
    shift
    SAGE_BANNER=no sage_setup
    export PYTHONIOENCODING="utf-8"  # Fix encoding for doctests
    exec sage-runtests -a "$@"
fi

if [ "$1" = '-c' ]; then
    shift
    SAGE_BANNER=no sage_setup
    unset TERM  # See Trac #12263
    exec sage-eval "$@"
fi

if [ "$1" = "-docbuild" -o "$1" = "--docbuild" ]; then
    shift
    exec python -m "sage_setup.docbuild" "$@"
fi

if [ "$1" = '-gdb' -o "$1" = "--gdb" ]; then
    shift
    sage_setup
    if [ "$SAGE_DEBUG" = "no" ]; then
        gdb -x "$SAGE_SCRIPTS_DIR/sage-gdb-commands" \
            -args python "$SAGE_SCRIPTS_DIR/sage-ipython" "$@" -i
    else
        cygdb "$SAGE_SRC/build" "$SAGE_SRC/sage" \
            -- -x "$SAGE_SCRIPTS_DIR/sage-gdb-commands" \
            -args python "$SAGE_SCRIPTS_DIR/sage-ipython" "$@" -i
    fi
    exit $?
fi

if [ "$1" = '-preparse' -o "$1" = "--preparse" ]; then
    shift
    exec sage-preparse "$@"
fi

if [ "$1" = "-cython" -o "$1" = '--cython' -o "$1" = '-pyrex' -o "$1" = "--pyrex" ]; then
    shift
    exec sage-cython "$@"
fi

if [ "$1" = '-valgrind' -o "$1" = "--valgrind" -o "$1" = '-memcheck' -o "$1" = "--memcheck" ]; then
    shift
    sage_setup
    exec sage-valgrind "$@"
fi

if [ "$1" = '-massif' -o "$1" = "--massif" ]; then
    shift
    sage_setup
    exec sage-massif "$@"
fi

if [ "$1" = '-cachegrind' -o "$1" = "--cachegrind" ]; then
    shift
    sage_setup
    exec sage-cachegrind "$@"
fi

if [ "$1" = '-callgrind' -o "$1" = "--callgrind" ]; then
    shift
    sage_setup
    exec sage-callgrind "$@"
fi

if [ "$1" = '-omega' -o "$1" = "--omega" ]; then
    shift
    sage_setup
    exec sage-omega "$@"
fi

if [ "$1" = '-startuptime' -o "$1" = '--startuptime' ]; then
    exec sage-startuptime.py "$@"
fi

if [ "$1" = '-gthread' -o "$1" = '-qthread' -o "$1" = '-q4thread' -o "$1" = '-wthread' -o "$1" = '-pylab' ]; then
    # Intentionally no "shift" here
    interactive_sage "$@"
fi

if [ $# -ge 1 ]; then
    SAGE_BANNER=no sage_setup
    unset TERM  # See Trac #12263
    exec sage-run "$@"
fi