From 3e31c0d61af43e9518581fce0bfac4f0ce22e1d6 Mon Sep 17 00:00:00 2001 From: Mitchell Paulus Date: Tue, 10 Dec 2024 12:37:54 -0600 Subject: [PATCH] Update README, improve long string debug --- README.md | 15 +++++++-------- lib/std.msh | 1 + mshell/MShellObject.go | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2a09143..acdde34 100644 --- a/README.md +++ b/README.md @@ -126,14 +126,6 @@ wt ((toFloat abs str) map wjoin wl) each ``` - - - - - - - - *Simpler execution of common shell idioms* @@ -141,9 +133,16 @@ wt ((toFloat abs str) map wjoin wl) each |-----------|-----|----------| | Print the number of files in the current directory | `ls \| wc -l` | `"*" glob len wl` | | `find`/`xargs` | `find . -t x -name '*.sh' -print0 \| xargs -0 mycommand` | `[mycommand [find . -t x -name "*.sh"]]o;` | +| `head` | `head -n 10` | .. :10 uw | +| `tail` | `tail -n 10` | .. :-10 uw | +| `wc` | `wc -l` | .. len wl | +| `grep` | `grep 'pattern'` | .. ("pattern" in) filter uw | +| `cut` | `cut -d ';' -f 2` | .. (";" split :1: wl) each | + # TODO - Type checking - Improved error messages - Dictionaries +- Built-in coreuitls, `cp`, `mv`, `rm`, `mkdir` diff --git a/lib/std.msh b/lib/std.msh index a9f3586..f3df728 100644 --- a/lib/std.msh +++ b/lib/std.msh @@ -118,3 +118,4 @@ end def tab " " end def tsplit tab split end +def uw unlines w end diff --git a/mshell/MShellObject.go b/mshell/MShellObject.go index 04e4add..9e3bcc5 100644 --- a/mshell/MShellObject.go +++ b/mshell/MShellObject.go @@ -353,7 +353,11 @@ func (obj *MShellList) DebugString() string { } func (obj *MShellString) DebugString() string { - // Surround the string with double quotes + // Surround the string with double quotes, keep just the first 15 and last 15 characters + if len(obj.Content) > 30 { + return "\"" + obj.Content[:15] + "..." + obj.Content[len(obj.Content)-15:] + "\"" + } + return "\"" + obj.Content + "\"" }