Skip to content

Commit 7b58777

Browse files
committed
feat: allow reading mail interactively with mail-in-ctr
1 parent 0dffda9 commit 7b58777

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

utils/mail-in-ctr.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ arg_quot () {
1212
printf '%s' "$@" | sed "s/'/'\\\\''/g; s/.*/'&'/"
1313
}
1414

15-
if [ "$(getopt -T > /dev/null; echo $?)" -eq 4 ]; then
15+
if [ $# -eq 0 ] && [ -t 0 ]; then
16+
: # interactive mode
17+
elif [ "$(getopt -T > /dev/null; echo $?)" -eq 4 ]; then
1618
# sed is to strip the extra -- param
1719
orig_opts=$(getopt -- '' -- "$@" | sed 's/^ *-- *//')
1820
# convert -. and --end-options to --
@@ -80,4 +82,4 @@ else
8082
echo "WARNING: $SELF_NAME: falling back to insecure parameter passing because this getopt is unsupported" >&2
8183
fi
8284

83-
exec ${CTR_EXEC_CMD:-podman exec} -i "$CTR_NAME" mail "$@"
85+
exec ${CTR_EXEC_CMD:-podman exec} -i $([ -t 0 ] && echo -t) "$CTR_NAME" mail "$@"

0 commit comments

Comments
 (0)