Browse Source

fix: allow direct action to receive ``stdin``

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
master
Valentin Lab 2 years ago
parent
commit
80f471c241
  1. 7
      bin/compose
  2. 6
      bin/compose-core

7
bin/compose

@ -1000,8 +1000,11 @@ run() {
set -- "${cmd_args[@]}"
fi
[ -t 0 ] && docker_run_opts+=("-i")
[ -t 1 ] && docker_run_opts+=("-t")
## XXXvlab: can't see a place where we wouldn't want to link stdin
## to internal process be it a terminal or not.
docker_run_opts+=("-i")
## If stdin is a not a tty, then adding ``-t`` will fail
[ -t 0 -a -t 1 ] && docker_run_opts+=("-t")
debug "${WHITE}Launching:${NORMAL}"
if [ -n "$DEBUG" ] || [ -n "$DRY_RUN" ]; then

6
bin/compose-core

@ -2677,7 +2677,7 @@ _run_service_action_direct() {
export SERVICE_CONFIGSTORE="$CONFIGSTORE/$service"
exname="$exname $ACTION_NAME $SERVICE_NAME" \
stdbuf -oL -eL bash -c 'charm.run_direct_action "$@"' -- "$charm" "$action" "$@"
)
) 0<&6 ## inject general stdin
}
export -f _run_service_action_direct
@ -2812,6 +2812,7 @@ export -f has_service_action
run_service_action () {
local service="$1" action="$2"
shift ; shift
exec 6<&0 ## saving stdin
{
if ! read-0 action_type; then
info "Service $DARKYELLOW$service$NORMAL does not have any action $DARKCYAN$action$NORMAL defined."
@ -2820,8 +2821,9 @@ run_service_action () {
fi
"_run_service_action_${action_type}" "$service" "$action" "$@"
} < <(has_service_action "$service" "$action")
exec 0<&6 6<&- ## restoring stdin
}
export -f run_service_action

Loading…
Cancel
Save