Skip to content

Commit

Permalink
issue#32: allow ad-hoc cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Flamm committed Aug 3, 2017
1 parent 3e05e02 commit 2935d92
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion afpre
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ do_version() {

do_help() {
! read -d '' HELP <<EOF
usage: ${0} [OPTIONS]
usage: ${0} [OPTIONS] (-- COMMAND)
OPTIONS
--help ... print this help
Expand Down Expand Up @@ -89,6 +89,10 @@ longoption_value() {
grep -o -- "--${1}=[^ ]*" <<< $ARGS| cut -d"=" -f2
}

get_command() {
grep -o -- '-- .*' <<< ${ARGS} | sed 's/^-- //g'
}

DEBUG=false
ARGS="${@}"

Expand Down Expand Up @@ -121,6 +125,11 @@ variable_true "${INSECURE}" && {
echo WARNING: configured to perform \"insecure\" SSL connections and transfers
}

ADHOC_CMD=$(get_command)
variable_empty "${ADHOC_CMD}" || {
CMD_AND_EXIT="eval \"\${PROMPT_COMMAND}\";${ADHOC_CMD};exit"
}

X1XBN02R=$(encode64 "${NAME}:${PW}")
RCFILE=$(mktemp)

Expand Down Expand Up @@ -189,6 +198,8 @@ PROMPT_COMMAND="{
}"
PS1="AFP|${PATTERN} \$PS1"
$CMD_AND_EXIT
EOF

bash --rcfile $RCFILE

0 comments on commit 2935d92

Please sign in to comment.