Created
May 23, 2023 06:07
-
-
Save drcircuit/79f6925ca9db06ee5aed52de5e0b5677 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| while getopts "dte:h?" opt ; do | |
| case "$opt" in | |
| h|\?) | |
| printf "usage: %s -e KEY=VALUE prog [args...]\n" $(basename $0) | |
| exit 0 | |
| ;; | |
| t) | |
| tty=1 | |
| gdb=1 | |
| ;; | |
| d) | |
| gdb=1 | |
| ;; | |
| e) | |
| env=$OPTARG | |
| ;; | |
| esac | |
| done | |
| shift $(expr $OPTIND - 1) | |
| prog=$(readlink -f $1) | |
| shift | |
| if [ -n "$gdb" ] ; then | |
| if [ -n "$tty" ]; then | |
| touch /tmp/gdb-debug-pty | |
| exec env - $env TERM=screen PWD=$PWD gdb -tty /tmp/gdb-debug-pty --args $prog "$@" | |
| else | |
| exec env - $env TERM=screen PWD=$PWD gdb --args $prog "$@" | |
| fi | |
| else | |
| exec env - $env TERM=screen PWD=$PWD $prog "$@" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment