mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-12-22 01:50:44 -06:00
fix(#2): use bash/zsh only
This commit is contained in:
parent
e85d61c6e1
commit
b7a6929276
3 changed files with 16 additions and 22 deletions
|
@ -27,9 +27,6 @@ tconfirm = $(call py,confirm_py,$(1))
|
||||||
.PHONY: h help _help _print-ansi _update-task.mk
|
.PHONY: h help _help _print-ansi _update-task.mk
|
||||||
TASK_MAKEFILE_LIST := $(filter-out $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
TASK_MAKEFILE_LIST := $(filter-out $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||||
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
|
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
|
||||||
# ifndef INHERIT_SHELL
|
|
||||||
# SHELL := $(shell which bash)
|
|
||||||
# endif
|
|
||||||
ifdef PHONIFY
|
ifdef PHONIFY
|
||||||
$(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
|
$(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -4,15 +4,15 @@
|
||||||
# possible posix process substitions solution:
|
# possible posix process substitions solution:
|
||||||
# https://unix.stackexchange.com/a/639752
|
# https://unix.stackexchange.com/a/639752
|
||||||
# -###
|
# -###
|
||||||
SHELL_CHECK ?= $(shell /bin/sh --version | grep 'bash|zsh|ksh')
|
TASKMK_SHELL ?= $(shell cat /etc/shells | grep -E '/(bash|zsh)' | head -n 1)
|
||||||
ifndef SHELL_CHECK
|
ifndef TASKMK_SHELL
|
||||||
$(error task.mk requires a process substition compatible shell)
|
$(warning WARNING! task.mk features require bash or zsh)
|
||||||
endif
|
endif
|
||||||
define _newline
|
define _newline
|
||||||
|
|
||||||
|
|
||||||
endef
|
endef
|
||||||
_escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
_escape_shellstring = $(subst ','\'',$(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1)))))
|
||||||
_escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
_escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
||||||
_create_string = $(subst $(_newline),\n,$(call _escape_shellstring,$(call _escape_printf,$1)))
|
_create_string = $(subst $(_newline),\n,$(call _escape_shellstring,$(call _escape_printf,$1)))
|
||||||
_printline = printf -- "<----------------------------------->\n"
|
_printline = printf -- "<----------------------------------->\n"
|
||||||
|
@ -26,7 +26,7 @@ endef
|
||||||
py = $(call _debug_runner,Python,python3,$($(1)))
|
py = $(call _debug_runner,Python,python3,$($(1)))
|
||||||
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
||||||
else
|
else
|
||||||
py = @python3 <(printf "$(call _create_string,$($(1)))")
|
py = @$(TASKMK_SHELL) -c 'python3 <(printf "$(call _create_string,$($(1)))")'
|
||||||
tbash = @bash <(printf "$(call _create_string,$($(1)))")
|
tbash = @$(TASKMK_SHELL) -c '$(TASKMK_SHELL) <(printf "$(call _create_string,$($(1)))")'
|
||||||
endif
|
endif
|
||||||
py-verbose = python3 <(printf "$(call _create_string,$($(1)))")
|
py-verbose = $(TASKMK_SHELL) -c 'python3 <(printf "$(call _create_string,$($(1)))")'
|
||||||
|
|
21
task.mk
21
task.mk
|
@ -1,7 +1,7 @@
|
||||||
# }> [github.com/daylinmorgan/task.mk] <{ #
|
# }> [github.com/daylinmorgan/task.mk] <{ #
|
||||||
# Copyright (c) 2022 Daylin Morgan
|
# Copyright (c) 2022 Daylin Morgan
|
||||||
# MIT License
|
# MIT License
|
||||||
TASKMK_VERSION ?= v23.1.1-8-gbddd2f3-dev
|
TASKMK_VERSION ?= v23.1.1-10-ge85d61c-dev
|
||||||
# task.mk should be included at the bottom of your Makefile with `-include .task.mk`
|
# task.mk should be included at the bottom of your Makefile with `-include .task.mk`
|
||||||
# See below for the standard configuration options that should be set prior to including this file.
|
# See below for the standard configuration options that should be set prior to including this file.
|
||||||
# You can update your .task.mk with `make _update-task.mk`
|
# You can update your .task.mk with `make _update-task.mk`
|
||||||
|
@ -391,15 +391,15 @@ def parseargs(argstring):
|
||||||
endef
|
endef
|
||||||
# ---- [python/bash script runner] ---- #
|
# ---- [python/bash script runner] ---- #
|
||||||
|
|
||||||
SHELL_CHECK ?= $(shell /bin/sh --version | grep 'bash|zsh|ksh')
|
TASKMK_SHELL ?= $(shell cat /etc/shells | grep -E '/(bash|zsh)' | head -n 1)
|
||||||
ifndef SHELL_CHECK
|
ifndef TASKMK_SHELL
|
||||||
$(error task.mk requires a process substition compatible shell)
|
$(warning WARNING! task.mk features require bash or zsh)
|
||||||
endif
|
endif
|
||||||
define _newline
|
define _newline
|
||||||
|
|
||||||
|
|
||||||
endef
|
endef
|
||||||
_escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
_escape_shellstring = $(subst ','\'',$(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1)))))
|
||||||
_escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
_escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
||||||
_create_string = $(subst $(_newline),\n,$(call _escape_shellstring,$(call _escape_printf,$1)))
|
_create_string = $(subst $(_newline),\n,$(call _escape_shellstring,$(call _escape_printf,$1)))
|
||||||
_printline = printf -- "<----------------------------------->\n"
|
_printline = printf -- "<----------------------------------->\n"
|
||||||
|
@ -413,10 +413,10 @@ endef
|
||||||
py = $(call _debug_runner,Python,python3,$($(1)))
|
py = $(call _debug_runner,Python,python3,$($(1)))
|
||||||
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
||||||
else
|
else
|
||||||
py = @python3 <(printf "$(call _create_string,$($(1)))")
|
py = @$(TASKMK_SHELL) -c 'python3 <(printf "$(call _create_string,$($(1)))")'
|
||||||
tbash = @bash <(printf "$(call _create_string,$($(1)))")
|
tbash = @$(TASKMK_SHELL) -c '$(TASKMK_SHELL) <(printf "$(call _create_string,$($(1)))")'
|
||||||
endif
|
endif
|
||||||
py-verbose = python3 <(printf "$(call _create_string,$($(1)))")
|
py-verbose = $(TASKMK_SHELL) -c 'python3 <(printf "$(call _create_string,$($(1)))")'
|
||||||
# ---- [builtin recipes] ---- #
|
# ---- [builtin recipes] ---- #
|
||||||
ifeq (help,$(firstword $(MAKECMDGOALS)))
|
ifeq (help,$(firstword $(MAKECMDGOALS)))
|
||||||
HELP_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
HELP_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
||||||
|
@ -444,11 +444,8 @@ tprint = $(call py,print_py,$(1))
|
||||||
tprint-verbose= $(call py-verbose,print_py,$(1))
|
tprint-verbose= $(call py-verbose,print_py,$(1))
|
||||||
tconfirm = $(call py,confirm_py,$(1))
|
tconfirm = $(call py,confirm_py,$(1))
|
||||||
.PHONY: h help _help _print-ansi _update-task.mk
|
.PHONY: h help _help _print-ansi _update-task.mk
|
||||||
TASK_MAKEFILE_LIST := $(filter-out $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
TASK_MAKEFILE_LIST := $(filter-out .task.cfg.mk .task.mk,$(MAKEFILE_LIST))
|
||||||
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
|
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
|
||||||
# ifndef INHERIT_SHELL
|
|
||||||
# SHELL := $(shell which bash)
|
|
||||||
# endif
|
|
||||||
ifdef PHONIFY
|
ifdef PHONIFY
|
||||||
$(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
|
$(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in a new issue