From cea860a44799d573eca3be75e2149fcb8863fe47 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Mon, 3 Nov 2025 19:25:24 -0500 Subject: [PATCH] some bug fixes --- all_for_testing.d | 1 + minigui.d | 14 +++++++++++- shell.d | 57 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/all_for_testing.d b/all_for_testing.d index 1647810..3f4a651 100644 --- a/all_for_testing.d +++ b/all_for_testing.d @@ -98,6 +98,7 @@ import arsd.rtf; // import arsd.screen; // D1 or 2.098 import arsd.script; import arsd.sha; +import arsd.shell; import arsd.simpleaudio; import arsd.simpledisplay; import arsd.sqlite; diff --git a/minigui.d b/minigui.d index a730575..88392f1 100644 --- a/minigui.d +++ b/minigui.d @@ -17879,15 +17879,26 @@ class FilePicker : Dialog { return -1; enum specialZoneSize = 1; + string originalString = whole; + bool fallback; + + start_over: char current = whole[0]; - if(current >= '0' && current <= '9') { + if(!fallback && current >= '0' && current <= '9') { + // if this overflows, it can mess up the sort, so it will fallback to string sort in that event int accumulator; do { + auto before = accumulator; whole = whole[1 .. $]; accumulator *= 10; accumulator += current - '0'; current = whole.length ? whole[0] : 0; + if(accumulator < before) { + fallback = true; + whole = originalString; + goto start_over; + } } while (current >= '0' && current <= '9'); return accumulator + specialZoneSize + cast(int) char.max; // leave room for symbols @@ -18277,6 +18288,7 @@ private FileType getFileType(string name) { auto ret = stat((name ~ '\0').ptr, &buf); if(ret == -1) return FileType.error; + // FIXME: what about a symlink to a dir? S_IFLNK then readlink then i believe stat it again. return ((buf.st_mode & S_IFMT) == S_IFDIR) ? FileType.dir : FileType.other; } else assert(0, "Not implemented"); } diff --git a/shell.d b/shell.d index 2ec8df2..128106e 100644 --- a/shell.d +++ b/shell.d @@ -10,6 +10,49 @@ History: Added October 18, 2025 + + Bugs: + $(LIST + * < and > redirections are not implemented at all + * >> not implemented + * | on Windows is not implemented + * glob expansion is minimal - * works, but no ?, no {item,other}, no {start..end} + * ~ expansion is not implemented + * `substitution` and $(...) is not implemented + * variable expansion is not implemented. can do $IDENT and ${IDENT} i think + * built-ins don't exist - `set`, want `for` and then like `export` and a way to hook in basic utilities polyfills especially on Windows (ls, rm, grep, etc) + * built-ins should have a pipe they can read/write to and return an int. integrate with arsd.cli? + * no !history recall. or history command in general + * job control is rudimentary - no fg, bg, jobs, &, ctrl+z, etc. + * set -o ignoreeof + * the path search is hardcoded + * prompt could be cooler + PS1 = normal prompt + PS2 = continuation prompt + Bash shell executes the content of the PROMPT_COMMAND just before displaying the PS1 variable. + + bash does it with `\u` and stuff but i kinda thiink using `$USER` and such might make more sense. + * it prints command return values when you might not want that + * LS_COLORS env var is not set + * && and || is not implemented + * the api is not very good + * ulimit? sourcing things too. aliases. + * see my bash rc for other little things. maybe i want a deeshrc + * permission denied when hitting tab on Windows + * tab complete of available commands not implemented - get it from path search. + * some vars dynamic like $_ being the most recent command, $? being its return value, etc + ) + + Questionable_ideas: + $(LIST + * separate stdout and stderr more by default, allow stderr pipes. + * custom completion scripts? prolly not bash compatible since the scripts would be more involved + * some kind of scriptable cmdlet? a full on script language with shell stuff embeddable? + see https://hush-shell.github.io/cmd/index.html for some ok ideas + * do something fun with job control. idk what tho really. + * can terminal emulators get notifications when the foreground process group changes? i don't think so but i could make a "poll again now" sequence since i control shell and possibly terminal emulator now. + * change DISPLAY and such when attaching remote sessions + ) +/ module arsd.shell; @@ -424,6 +467,12 @@ ShellCommand[] parseShellCommand(ShellLexeme[] lexemes, ShellContext context, Gl ShellCommand currentCommand; ShellCommand firstCommand; + enum ParseState { + lookingForVarAssignment, + lookingForArg, + } + ParseState parseState = ParseState.lookingForVarAssignment; + while(lexemes.length) { auto component = nextComponent(lexemes); if(component.length) { @@ -451,12 +500,6 @@ ShellCommand[] parseShellCommand(ShellLexeme[] lexemes, ShellContext context, Gl BUT THIS IS MY SHELL I CAN DO WHAT I WANT!!!!!!!!!!!! +/ - enum ParseState { - lookingForVarAssignment, - lookingForArg, - } - ParseState parseState = ParseState.lookingForVarAssignment; - bool thisWasEnvironmentPair = false; EnvironmentPair environmentPair; bool thisWasRedirection = false; @@ -718,7 +761,7 @@ class Shell { auto commands = parseShellCommand(lexShellCommandLine(commandLine), context, &globberForwarder); foreach(command; commands) try { - //dumpCommand(command); + dumpCommand(command); version(Posix) { import core.sys.posix.unistd;