printsty["cyan"]"│ 0 │"sty["green"]" y "sty["cyan"]"│"sty["green"]" github "sty["yellow"]"│"sty["green"]" Press Enter or type y to choose github "sty["yellow"]"│"
printsty["cyan"]"│ 1 │"sty["magenta"]" n "sty["cyan"]"│"sty["magenta"]" gitee "sty["yellow"]"│"sty["magenta"]" Type n to choose gitee "sty["yellow"]"│"
# [[Option, Description, yes, no]; ["[Y/n]","Default is yes", "Press Enter", "Type n and press Enter" ] , ["[y/N]","Default is no", "Type y and press Enter", "Press Enter"]]
print"However, it is still "sty["rd"]"the old edition."sty[0]
print"There are many, many illogical designs in the old edition. To be honest, I don't particularly recommend it."
print"You may have heard of it before, and I will rewrite it."
print"Before, you probably installed it with `master/debian.sh` or `2/2`. Now it's `2/2.awk`."
print"What you see now is written in awk."
print"This file is just used to guide you through the installation of tmm."
print"For the other tools, I should write it in another language."
print"To be honest, I really like rust."
print"But due to my poor knowledge of the underlying operating system, and my lack of familiarity with rust asynchronous and unsafe. So I'm not ready yet."
printsty["~"]"Perhaps I should rewrite it quickly in `nu` and then rewrite it again in `rust`."sty["/~"]
print"In fact, I don't have that much time."
print"I am sorry that I did not fulfil your expectations."
print"\n"
print"Enough about the new edition, let's get to know",sty["yl"]"the old one!"
# [[fallback2, fallback, fallback0]; ["zh my => zh sg", "zh => zh cn", "zh cn => en"], ["If the key is pineapple. MY cannot find the value corresponding to this key, then it will fall back to SG. If found, return '黄梨'. If not found, fallback2 => fallback", "If fallback is cn for the zh language. hk => cn, mo => cn, tw => cn. If fallback2 has no value, then it is '菠萝' in fallback. If fallback has no value, fallback => fallback0", "At fallback0 there is no way back. Here, it is neither '黄梨' nor '菠萝', but pineapple"] ]
print"You have already installed an older version, which has serious problems and will be removed automatically. You will need to re-run this awk file."
printsty["red"]"Error!",sty["yellow"]"Since the",sty["blue"]"TMPDIR"sty["yellow"]"environment variable does not exist, the temporary directory is",sty["green"]cache_dirsty["magenta"]", but it failed to be created."sty[0]
# Some systems do not have "/dev/tty" or "/proc/self/fd/0"
# Some awk distros do not support "-"
# Interestingly, for busybox awk on windows (busybox: v1.36.0-FRP-4621-gf3c5e8bc3 (2022-02-28 07:17:58 GMT)), it automatically converts "/dev/stdin" to the windows interface, but neither "/dev/tty" or "-" will work.
# In mawk(1.3.4 20200120), an explicit call to `close("/dev/stdin")` will result in a segmentation fault.
#
functionset_const(){
STDIN="/dev/stdin"
NONE=""
SPACE=" "
TO_NULL=" >/dev/null"
STDERR="/dev/stderr"
# true and false are not keywords in the current awk
arr_len=split("-v type aa bb cc dd 1.2e-3 ff 0x09",arg,SPACE)
print"arr.len(): "arr_len
for(iinarg)
printi,":",arg[i]
status=is_cmd_exists(cmd,arg,arr_len)
print_bool(status)
}
# -----------
#[test]
functiontest_check_cmd(){
WHICH_CMD=get_which_cmd()
print"WHICH_CMD:",WHICH_CMD
s=check_cmd("uname","-m")
print_bool(s)
}
# -----------
#[test]
functiontest_alice_s_fruit(_,s,fruit,my,alice){
s=""
fruit="lychees"
if(is_empty(s)){
print"s is empty\n",
"OK, I knew there was nothing there."
}
# note: my[fruit] is my["lychees"], not my["fruit"]
my[fruit]=2
if(is_empty(my[fruit])){
printf("Since the value of `my[fruit]` has already been defined earlier, don't be too sad.\n",
"The `if` will not go through this branch.\n")
}else{
printf("Please note that there is a difference between a variable that is empty and has the value \"\" and a variable that is not empty and has the value 0.\n",
"But in awk, if an int variable is uninitialized, it will automatically be set to 0.\n",
"Fortunately, mawk/gawk can call `typeof()` to check the type of a variable. We can determine (unassigned|undefined). Unfortunately, some awk distros do not have `typeof()`\n")
print(my[fruit]==0)?"The sad thing is that I don't have any "fruit:(my[fruit]==1)?"Only one, but no bad":"Woo-hoo! It's so exciting. I have many many",fruit
# thumbv7neon-linux-androideabi, Thumb2-mode ARMv7a Android with NEON
arch["llvm"]="armv7"
arch["deb"]="armhf"
# armel|armv6
}elseif(a~/arm(el|v6)/){
arch["llvm"]="arm"
# On some systems, arm-unknown-linux-gnueabihf might be "armhf"
# note: arm-unknown-linux-gnueabi and arm-unknown-linux-musleabi are "armel"
arch["deb"]="armel"
# To be honest, I don't want to support the armv6 and v5 architectures.
# Maybe one day I will remove or comment out these `else if`
}elseif(a~/arm(el|v5)/){
arch["llvm"]="armv5te"
arch["deb"]="armel"
}elseif(a~/arm/){
# armv4 or older architectures are not supported, if none of the above arm architectures are matched then the default will be to fall back to arm64
arch["llvm"]="aarch64"
arch["deb"]="arm64"
# i386 i486 i586 x86 x32 x86_32
}elseif(a~/x((86_)?32|86)|i[3-5]86/){
# note: On some systems it will output i386 even if it is i686.
print"It does not support i386 and i486, only i586 and i686"
arch["llvm"]="i586"
arch["deb"]="i386"
}elseif(a~/i686/){
arch["llvm"]="i686"
arch["deb"]="i386"
}elseif(a~/riscv64/){
arch["llvm"]="riscv64gc"
arch["deb"]="riscv64"
}elseif(a~/powerpc64(el|le)?|ppc64(el|le)?/){
print"It does not support ppc64, only ppc64el"
arch["llvm"]="powerpc64le"
arch["deb"]="ppc64el"
}elseif(a~/s390/){
# regex: Use /s390/, not /s390x/
arch["llvm"]=arch["deb"]="s390x"
}elseif(a~/mips64/){
arch["llvm"]=arch["deb"]="mips64el"
}elseif(a~/mips/){
# note: On mipsel devices, the output of `uname -m` may not be mipsle/mispel, but mips
arch["llvm"]=arch["deb"]="mipsel"
}else{
printsty["cyan"]
print"╭────┬─────────────┬────────────────╮"
print"│ # │ llvm_arch │ deb_arch │"
print"├────┼─────────────┼────────────────┤"
print"│ 0 │ x86_64 │ amd64 │"
print"│ 1 │ aarch64 │ arm64 │"
print"│ 2 │ armv7 │ armhf or armel │"
print"│ 3 │ arm │ armel │"
print"│ 4 │ armv5te │ armel │"
print"│ 5 │ i686 │ i386 │"
print"│ 6 │ riscv64gc │ riscv64 │"
print"│ 7 │ powerpc64le │ ppc64el │"
print"│ 8 │ s390x │ s390x │"
print"│ 9 │ mips64el │ mips64el │"
print"│ 10 │ mipsel │ mipsel │"
print"╰────┴─────────────┴────────────────╯"
printsty["green"]"Note: There is a difference between",sty["blue"]"arm-unknown-linux-gnueabi",sty["cyan"]"and",sty["yellow"]"arm-unknown-linux-gnueabihf."sty[0]
print"On some systems, the latter may be",sty["yellow"]"armhf",sty[0]"instead of",sty["blue"]"armel."
printsty["yellow"]"---------------------"
# print "Adapting to different architectures is hard work. To be honest, I don't want to be that tired."
printsty["red"]"Unfortunately!\n",
sty["blue"]"It does not support the",sty["magenta"]a,sty["cyan"]"architecture."sty[0]>STDERR