@@ -866,3 +866,70 @@ term.underline() {
866866term.strikethrough () {
867867 term.style_strikethrough " $@ "
868868}
869+
870+ term._util_validate_p () {
871+ local args_excluding_flags=" $1 "
872+ if ! shift ; then core.panic ' Failed to shift' ; fi
873+
874+ if (( $# - 1 > args_excluding_flags)) ; then
875+ core.panic ' Incorrect argument count'
876+ elif (( $# - 1 == args_excluding_flags)) ; then
877+ if [[ $1 == -? (@ (p| P)) ]]; then
878+ case $1 in
879+ * p* ) flag_print=' yes' ;;
880+ * P* ) flag_print=' yes-newline' ;;
881+ esac
882+ REPLY_SHIFT=1
883+ else
884+ core.panic ' Invalid flag'
885+ fi
886+ else
887+ REPLY_SHIFT=0
888+ fi
889+
890+ }
891+
892+ term._util_validate_pd () {
893+ local args_excluding_flags=" $1 "
894+ if ! shift ; then core.panic ' Failed to shift' ; fi
895+
896+ if (( $# - 1 == args_excluding_flags)) ; then
897+ if [[ $1 == -? (d| @ (p| P)| d@ (p| P)| @ (p| P)d) ]]; then
898+ case $1 in
899+ * p* ) flag_print=' yes' ;;
900+ * P* ) flag_print=' yes-newline' ;;
901+ esac
902+ if [[ $1 == * d* ]]; then
903+ end=$' \e [0m'
904+ fi
905+ REPLY_SHIFT=1
906+ else
907+ core.panic ' Invalid flag'
908+ fi
909+ elif (( $# > args_excluding_flags)) ; then
910+ core.panic ' Incorrect argument count'
911+ else
912+ REPLY_SHIFT=0
913+ fi
914+ }
915+
916+ term._util_set_reply () {
917+ local value=" $1 "
918+
919+ REPLY=" $value "
920+ term._util_replyprint
921+ }
922+
923+ term._util_set_reply2 () {
924+ # shellcheck disable=SC2059
925+ printf -v REPLY " $@ "
926+ term._util_replyprint
927+ }
928+
929+ term._util_replyprint () {
930+ if [ " $flag_print " = ' yes' ]; then
931+ printf ' %s' " $REPLY "
932+ elif [ " $flag_print " = ' yes-newline' ]; then
933+ printf ' %s\n' " $REPLY "
934+ fi
935+ }
0 commit comments