fix issue with coloring-via-|sed != tty

This commit is contained in:
Alexander Mahr 2024-12-28 11:02:16 +01:00
parent e6df08287e
commit f9302f11a7
3 changed files with 26 additions and 14 deletions

View file

@ -13,11 +13,21 @@ test -n "$LINES" || {
test -n "$LINES" || { test -n "$LINES" || {
read -r LINES COLUMNS < <(stty size) read -r LINES COLUMNS < <(stty size)
} }
test -n "$LINES" || {
test -z "$LINES" && {
LINES=25 LINES=25
COLUMS=80 }
test "$LINES" -lt "16" && {
LINES=16
} }
test -z "$COLUMNS" && {
COLUMNS=80
}
test "$COLUMNS" -lt "36" && {
COLUMNS=36
}
type whiptail &>/dev/null && { type whiptail &>/dev/null && {
ECHO(){ ECHO(){

View file

@ -1,4 +1,5 @@
SHELL=/bin/bash .ONESHELL:
SHELL=/bin/makefile-bash-wrapper.sh
# symlink # symlink
./app.apk: ./result/app.apk ./app.apk: ./result/app.apk

View file

@ -32,6 +32,15 @@ ENV BUILD_TOOLS_LATEST="$ANDROID_SDK_ROOT/cmdline-tools/latest"
ENV PATH="$BUILD_TOOLS_LATEST/bin:$PATH" ENV PATH="$BUILD_TOOLS_LATEST/bin:$PATH"
ENV LIBRARY_PATH="$LIBRARY_PATH:$BUILD_TOOLS_LATEST/lib" ENV LIBRARY_PATH="$LIBRARY_PATH:$BUILD_TOOLS_LATEST/lib"
CMD ["make","--trace"] CMD ["make","--trace"]
RUN <<EOF
cat > /bin/makefile-bash-wrapper.sh << 'WRAPPER'
#!/bin/bash
printf $'\033[0;32m''#----------------------------------------\n'$'\033[0m' >&2
bash "$@"
printf '\n\n\n\n' >&2
WRAPPER
chmod u+x /bin/makefile-bash-wrapper.sh
EOF
DOCKERFILEEOF DOCKERFILEEOF
} }
@ -53,18 +62,10 @@ docker tag $IMAGE build-android-app:latest
time $CONTAINERRUNTIME run --name build-android-app-$(date +%F--%H-%M-%S) \ time $CONTAINERRUNTIME run --name build-android-app-$(date +%F--%H-%M-%S) \
--workdir=/app \ --workdir=/app \
--env LINES=10 \
--env COLUMNS=$COLUMNS \
--hostname build-android-app \ --hostname build-android-app \
--volume ./app:/app \ --volume ./app:/app \
-it \ -it \
--rm \ --rm \
"$IMAGE" "$@" | { "$IMAGE" "$@"
test "$#" -eq 0 && {
# colur output in case this script was called without]
# command line arguments
sed 's/^Makefile:/\n\n'$'\033[0;32m''Makefile:'$'\033[0m''/g'
} || {
# no modification else
cat
}
}