Skip to content

Commit

Permalink
Update README, improve long string debug
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchpaulus committed Dec 10, 2024
1 parent 74be3c8 commit 3e31c0d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,23 @@ wt ((toFloat abs str) map wjoin wl) each
```
<!-- | Objective | `awk` | `mshell` | -->
<!-- |-----------|-------|----------| -->
<!-- | Print the total number of input lines | `END { print NR }` | `.. len wl` | -->
<!-- | Print the 10th input line | `NR == 10` | `.. :10: wl` (Failure if < 10 lines) | -->
<!-- | Print the last field of every input line | `{ print $NF }` | `.. (ws split :-1: wl) each` | -->
<!-- | Print the last field of the last input line | `{ field = $NF } END { print field }` | `.. :-1: (ws split :-1: wl)` | -->
<!-- | Print every input line with more than four fields | `NF > 4` | `.. (dup ws split len [(4 >) (wl) (drop)] if) each` | -->
*Simpler execution of common shell idioms*
| Objective | `sh` | `mshell` |
|-----------|-----|----------|
| 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`
1 change: 1 addition & 0 deletions lib/std.msh
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,4 @@ end

def tab " " end
def tsplit tab split end
def uw unlines w end
6 changes: 5 additions & 1 deletion mshell/MShellObject.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "\""
}

Expand Down

0 comments on commit 3e31c0d

Please sign in to comment.