summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-08-25 19:20:43 +0200
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-08-25 19:20:43 +0200
commit171651223d0e8bc6cdd1cf4577bc119e4fc8b353 (patch)
tree68f0e33c4c8c2afab5c09102a45562c8b49ce339
parentdfaaf6172ff1f7fe6b9090e66ca26e316dedc3ac (diff)
downloadmidipix_build-171651223d0e8bc6cdd1cf4577bc119e4fc8b353.tar.bz2
midipix_build-171651223d0e8bc6cdd1cf4577bc119e4fc8b353.tar.xz
subr/build_init.subr:buildp_init_getopts(): filter etc/build.usage{,.short} if stdout does not refer to a tty.
subr/pkgtool_init.subr:pkgtoolp_init_getopts_help(): filter etc/pkgtool.usage if stdout does not refer to a tty.
-rw-r--r--subr/build_init.subr14
-rw-r--r--subr/pkgtool_init.subr7
2 files changed, 18 insertions, 3 deletions
diff --git a/subr/build_init.subr b/subr/build_init.subr
index 8933fff1..3d8a42c9 100644
--- a/subr/build_init.subr
+++ b/subr/build_init.subr
@@ -142,7 +142,12 @@ buildp_init_getopts() {
--dump-on-abort)
ARG_DUMP_ON_ABORT=1; _shiftfl=1; ;;
--debug-minipx) ARG_DEBUG_MINIPIX=1; _shiftfl=1; ;;
- --help) cat etc/build.usage; exit 0; ;;
+ --help)
+ if [ -t 1 ]; then
+ cat etc/build.usage;
+ else
+ sed 's/\[[0-9]\+m//g' etc/build.usage;
+ fi; exit 0; ;;
--reset-state) ARG_RESET_PKG=1; _shiftfl=1; ;;
-v*) _opt="${1#-}"; while [ -n "${_opt}" ]; do
: $((_verbose+=1)); _opt="${_opt#?}";
@@ -175,7 +180,12 @@ buildp_init_getopts() {
C) ARG_CLEAN_BUILDS="${OPTARG}"; ;;
D) ARG_DIST="${OPTARG}"; ;;
F) ARG_FETCH_FORCE="${OPTARG}"; ;;
- h) cat etc/build.usage.short; exit 0; ;;
+ h)
+ if [ -t 1 ]; then
+ cat etc/build.usage.short;
+ else
+ sed 's/\[[0-9]\+m//g' etc/build.usage.short;
+ fi; exit 0; ;;
p) ARG_PARALLEL="${OPTARG}"; ;;
P) ARG_PARALLEL="auto";
if [ -n "${2:-}" ]\
diff --git a/subr/pkgtool_init.subr b/subr/pkgtool_init.subr
index b7c04c70..1bbcbf75 100644
--- a/subr/pkgtool_init.subr
+++ b/subr/pkgtool_init.subr
@@ -87,7 +87,12 @@ pkgtoolp_init_getopts_help() {
local _opt="";
while getopts a:b:hirst _opt 2>/dev/null; do
case "${_opt}" in
- h) cat etc/pkgtool.usage; exit 0; ;;
+ h)
+ if [ -t 1 ]; then
+ cat etc/pkgtool.usage;
+ else
+ sed 's/\[[0-9]\+m//g' etc/pkgtool.usage;
+ fi; exit 0; ;;
esac; done; shift $((${OPTIND}-1));
};