use try/case instead of idx/switch

This commit is contained in:
2026-04-19 09:02:33 +02:00
parent f7cda17924
commit 524cf4d2e7

18
uash.ua
View File

@@ -9,10 +9,8 @@
] ]
ColorCode ↚ ˜⊂"\x1b[0m" ⊂$"\x1b[1;3_m" ColorCode ↚ ˜⊂"\x1b[0m" ⊂$"\x1b[1;3_m"
C ↚ ( C ↚ (
⨂{"truecolor"} □&var"COLORTERM" ⍣(⍩(ColorCode get ⊙COLORS) °"truecolor" &var"COLORTERM"
⨬(ColorCode get ⊙COLORS | ∘)
| ◌
)
) )
PS₁ ← &pf ⊂(C"blue" Pretty)(°&cd C"green" " λ ") PS₁ ← &pf ⊂(C"blue" Pretty)(°&cd C"green" " λ ")
@@ -21,17 +19,15 @@
┌─╴Commands ┌─╴Commands
# ? {"cd" ...} # ? {"cd" ...}
CD ← ( CD ← (
⨂[0 1]⊸⧻ ↘1 ⍣(⍩(&cd&var"HOME") °0⧻↘1
⨬(&cd&var"HOME" | ⍩(⍣&cd(&ep"cd: invalid path") ⊢) °1⊸⧻↘1
| ⍣&cd(&ep"cd: invalid path") ⊢
| &ep"cd: too many arguments") | &ep"cd: too many arguments")
) )
# ? {"exit" [code]} # ? {"exit" [code]}
Exit ← ( Exit ← |1.0 (
⨂[0 1]⊸⧻ ↘1 ⍣(⍩(&exit 0) °0⧻↘1
(&exit 0 | ⍩(&exit ⋕°□⊢) °1⊸⧻↘1
| &exit ⋕°□⊢
| &ep"exit: too many arguments") | &ep"exit: too many arguments")
) )