Created
September 26, 2022 17:44
-
-
Save legionus/5b8661f3a10a79a8dc9d7c879592bf55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AAA_BBB = 123 | |
BBB-CCC = 456 | |
AAA1 = `echo $HOME` | |
_upper_ = A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | |
_lower_ = a b c d e f g h i j k l m n o p q r s t u v w x y z | |
_digits_ = 0 1 2 3 4 5 6 7 8 9 | |
define remove-recursive | |
$(if $(1),$(call remove-recursive,$(wordlist 2,$(words $(1)),$(1)),$(subst $(firstword $(1)),,$(2))),$(2)) | |
endef | |
define starts-with | |
$(if $(1),$(if $(filter $(firstword $(1))%,$(2)),$(2),$(call starts-with,$(wordlist 2,$(words $(1)),$(1)),$(2))),) | |
endef | |
define invalid-shell-symbols | |
$(call remove-recursive,$(_upper_) $(_lower_) $(_digits_) _,$(1)) | |
endef | |
define public-shell-name | |
$(call starts-with,$(_upper_),$(1)) | |
endef | |
define shell-name-vars | |
$(foreach v,$(.VARIABLES),$(if $(call invalid-shell-symbols,$(v)),,$(call public-shell-name,$(v)))) | |
endef | |
define shell-export-vars | |
$(foreach v,$(shell-name-vars),export $(v)='$(subst ','\'',$(subst \,\\,$($(v))))'; | |
) | |
endef | |
$(shell $(shell-export-vars) true) | |
all: | |
@:; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment