~acdw/mrgrctrnl

2bed591dbe9324e91e59f2835d683f3ea2aa1d21 — Case Duckworth 1 year, 1 month ago 7ca3a30
Fix -r flag
1 files changed, 10 insertions(+), 7 deletions(-)

M mrgrctrnl
M mrgrctrnl => mrgrctrnl +10 -7
@@ 12,6 12,7 @@ main() {
	_RUN=true
	_LOG=true
	_USE_CONFIG=true
	_RESTART=false
	# options
	__CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/$PRGN/config"
	__PIDF="/tmp/$PRGN.pid"


@@ 19,9 20,6 @@ main() {
	__SSH="$(command -v autossh || command -v ssh)"
	__SSH_ARGS="-nT -N \"\$user@\$machine\" -L \"\$local:\$remote\""

	# save command invocation (for -r)
	printf '%s %s\n' "$PRGN" "$*" >"$__CMDF"

	# parse options
	while getopts hkrnqSAc:s: OPT; do
		case "$OPT" in


@@ 34,10 32,7 @@ main() {
			pkill -x "$PRGN"
			exit "$?"
			;;
		r)
			untunnel
			exec "$(cat "$__CMDF")"
			;;
		r) _RESTART=true ;;
		n) _RUN=false ;;
		q) _LOG=false ;;
		S) __SSH='ssh' ;;


@@ 52,6 47,14 @@ main() {
	done
	shift $((OPTIND - 1))

	# save command invocation (for -r)
	if $_RESTART; then
		untunnel
		exec "$PRGN" $(cat "$__CMDF")
	else
		printf '%s\n' "$*" >"$__CMDF"
	fi

	# make sure ssh is installed
	if ! command -v "$__SSH" >/dev/null; then
		log "Not installed: $__SSH"