Skip to content

Commit 39e4295

Browse files
author
newnix
committed
Minor Updates
* README.md - Add line breaks to goal list - Credit csh instead of bash for history manipulation functions - Add example of proposed grammar change - Include XXHash as an alternate hashing method - Include the possibility of using floating point internally for mathematical operations * dict.c - Use unsigned types for hashinng function * es.h - Add macro logic for using single debug switch * fd.c - Noted a section of code that needs revisiting as it currently relies on undefined behavior as reported by ubsan
1 parent 8bd918b commit 39e4295

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,33 +133,43 @@ Please read through README.orig to see the original text, especially as this is
133133
### Goals
134134
Some goals for the future of this fork (in no particular order):
135135
1. Modernize codebase (Drop obsolete hacks, attempt to make future maintenance easier)
136-
2. Add primitives to facilitate use as a glue language or midway point between POSIX `sh` and "real" languages like Racket/C/Python, etc.
136+
2. Add primitives to facilitate use as a glue language or midway point between POSIX
137+
`sh` and "real" languages like Racket/C/Python, etc.
137138
3. Work on making `nxes` tail recursive, this is mentioned in the original TODO (#2)
138-
4. Add some basic history manipulation commands such as `!!` and `!-2$` in GNU `bash` to aid in productivity
139+
4. Add some basic history manipulation commands such as `!!` and `!-2$`
140+
in `csh` to aid in productivity
139141
5. Allow subshells to inherit closures (#1 in original TODO)
140142
6. Potentially expose `%parse` in such a way as to create a simple macro system
141143
7. Simplify and streamline build process (remove ./configure, reduce needed system tests)
142144
8. Look at moving away from Yacc/Bison for writing the lexer/parser
143145
9. Allow for nested lists, in turn allowing for trees and other derived data structures
144146
10. Look into creating a `printf(1)` builtin for more complex printing needs than just `$&echo`
145-
11. Consider changing variable/function binding syntax using more LISP-like forms, this would free up `=` from being a special character, which should make flags requiring '=' (e.g. `clang -std=c99`) more ergonomic than with the current parsing grammar. (having to do `'='` or similar)
146-
12. Flesh out job control mechanism, support exists for creating new process groups and background execution, but no means to switch from background to foreground currently exists
147+
11. Consider changing variable/function binding syntax using more LISP-like forms (e.g. `def x 2`),
148+
this would free up `=` from being a special character, which should make flags requiring '='
149+
(e.g. `clang -std=c99`) more ergonomic than with the current parsing grammar.
150+
(having to do `'='` or similar)
151+
12. Flesh out job control mechanism, support exists for creating new process groups
152+
and background execution, but no means to switch from background to foreground currently exists
147153
13. Remove the dependency on GNU readline or libedit for common features like tab completion,
148154
making them optional for those who have a custom `.inputrc` that I have no intent to support.
149-
14. Investigate hashing methodology, consider something like FNV-1/FNV-1a hashing
155+
14. Investigate hashing methodology, consider something like FNV-1/FNV-1a/XXHash hashing
156+
15. Examine how difficult adding floating-point support is for numeric computations, this
157+
allows for significantly more potential uses, but adhering to IEEE 754 and making it user friendly
158+
enough to be used may not be worthwhile for a shell.
150159
151160
Some non-goals:
152161
1. Become a strict, functional programming language
153162
2. Become a lazy, functional programming language
154163
3. Rewrite in Rust or other language (maybe some day, but this is not a goal)
155-
4. Become feature compatible with GNU `bash` (or really any other shell, some features are nice, but let's keep things small)
164+
4. Become feature compatible with GNU `bash` (or really any other shell,
165+
some features are nice, but let's keep things small)
156166
157167
## See Also
158168
Unbeknownst to me, there are actually several forks with varying activity, including one by
159-
the user [wyrun](https://wyrun.github.io/es-shell/) that appears to be dedicated to preserving
169+
the user [wryun](https://wryun.github.io/es-shell/) that appears to be dedicated to preserving
160170
the history of `es(1)` while also working on some enhancements.
161171
162-
According to GitHub, there are at least [18 forks](https://github.com/wyrun/es-shell/network/members) of this repo alone.
172+
According to GitHub, there are at least [18 forks](https://github.com/wryun/es-shell/network/members) of this repo alone.
163173
While I continue work on `nxes(1)` as time permits, those interested in command interpreters
164174
may also want to check out these projects for some possible inspiration or even a starting
165175
point for yet another improved shell.

dict.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static unsigned long strhash2(const char *str1, const char *str2) {
3333
}\
3434
}
3535

36-
int c;
36+
unsigned int c;
3737
unsigned long n = 0;
3838
unsigned char *s = (unsigned char *) str1;
3939
assert(str1 != NULL);

es.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
#define ENV_ESCAPE '\002' /* control-B */
1212

1313
/* Setting this one macro should allow greater runtime introspection */
14-
#if DEBUG_ALL
14+
#if defined(DEBUG_ALL)
1515
#define GCDEBUG 1
1616
#define GCVERBOSE 1
1717
#define GCINFO 1
1818
#define LISPTREES 1
19-
#endif /* DEBUG_ALL */
20-
19+
/* Make sure asserts are included */
20+
#if defined(NDEBUG)
21+
#undef NDEBUG
22+
#endif /* defined(NDEBUG) */
2123
/* Warn whoever's compiling the code that DEBUG_ALL is meant to be super noisy */
22-
#ifdef DEBUG_ALL
2324
#warning "DEBUG_ALL makes nxes EXTREMELY noisy! It is meant for development NOT regular use!"
2425
#endif /* DEBUG_ALL */
2526

fd.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,13 @@ extern int fdmap(int fd) {
103103
return fd;
104104
}
105105

106+
/*
107+
* TODO: Investigate this function, UBSAN reports an issue
108+
* with applying a zero offset to a NULL pointer.
109+
*/
106110
/* remapfds -- apply the fd map to the current file descriptor table */
107111
static void remapfds(void) {
108-
Defer *defer, *defend = &deftab[defcount];
112+
Defer *defer, *defend = &deftab[defcount]; /* This is the issue UBSAN finds, need to investigate how to avoid it */
109113
for (defer = deftab; defer < defend; defer++) {
110114
unregisterfd(&defer->realfd);
111115
dodeferred(defer->realfd, defer->userfd);

0 commit comments

Comments
 (0)