grable 1 Posted April 22, 2015 Share Posted April 22, 2015 Hi, ive been playing with OpenComputers for a few days and i really like it And for that reason ive made some small modifications to OpenOS command/lib/boot files and thought they might be of some value to other people or possibly inclusion in vanilla OC. They are not big changes, but they make using OpenOS a bit closer to *nix. Changes: Removed hard coded aliases from shell. Removed hard coded environment variables from os. Added persistence of aliases to shell in /etc/shell.cfg. Added persistence of environment variables to os in /etc/env.cfg". Added environment variable export command. (for saving to disk) Addes -s -h -si switches to ls command. (shows file sizes without -l mode) Added LS_OPTIONS environment variable read by ls command. (for default options) Added -e switch to the unset command. (for removing exported environment variables) Added syntax highlighter library. (used by cedit and hl) Added syntax highlighting version of edit called cedit. Added syntax highlighting version of more called hl. Added inverted blinking cursor to term. (for cedit to show proper color and character under cursor) I put it up on GitHub as suggested, OpenOS-mods. Quote Link to post Share on other sites
dgelessus 26 Posted April 22, 2015 Share Posted April 22, 2015 Removed hard coded aliases from shell. Dunno, I haven't seen any Linux distro that doesn't do this. This would make more sense with the third change you suggested, then they could be part of the default config rather than /bin/sh.lua. Removed hard coded environment variables from os. Added persistence of environment variables to os in /etc/env.cfg". Added environment variable export command (for saving to disk). Well, the point of envvars is that they normally aren't permanent. On a normal Unix you'd set "permanent" envvars in the appropriate profile script, but there is no such thing in OpenOS, so the boot files are the most logical place to put those. Some kind of profile.lua would make more sense IMO. Added LS_OPTIONS environment variable read by ls command (for default options). Why not alias ls="ls --some --options --you --like"? Fixed os.setenv to check for empty strings as well as nil for deletion of environment variables. AFAICT empty-string is a valid envvar value. What my real sh says: $ env [...] TMP=/tmp USER=dgelessus _=/usr/bin/env $ env FOO='bar' [...] TMP=/tmp USER=dgelessus _=/usr/bin/env FOO=bar $ env FOO='' [...] TMP=/tmp USER=dgelessus _=/usr/bin/env FOO= Note how the first env call lists no FOO (obviously), but the third one does, even though FOO is an empty string. Thus there is an extra --unset option for env: $ env --unset TMP FOO='bar' [...] USER=dgelessus _=/usr/bin/env FOO=bar If any of the above sounded harsh, I didn't mean it that way. I've given my feedback on the things that I would disagree with if they were added to base OpenOS. This doesn't mean that I find the idea in general or the other changes bad - consider my opinion on everything that I didn't reply to "Good idea, don't see anything wrong with that." Quote Link to post Share on other sites
grable 1 Posted April 22, 2015 Author Share Posted April 22, 2015 Dunno, I haven't seen any Linux distro that doesn't do this. This would make more sense with the third change you suggested, then they could be part of the default config rather than /bin/sh.lua. They are not part of /bin/sh.lua at all, but the shell library, so any shell can benefit from them. And the only reason i removed them was beacuse of the persistence. The default ones are still there, just in the config file. Well, the point of envvars is that they normally aren't permanent. On a normal Unix you'd set "permanent" envvars in the appropriate profile script, but there is no such thing in OpenOS, so the boot files are the most logical place to put those. Some kind of profile.lua would make more sense IMO. They are only permanent if they are exported, and the default ones are in the config file instead. Now i know export on real unixes only exports it to the environment, but i needed something to make them permanent and it was close enough. Some kind of profile would probably be better, but seing as OpenOS is a single user and single tasking os i dont se a big need for it yet. And by keeping them seperate, it allso keeps the pressure off each component having to reparse a large file and picking out its bits.. And saving allso becomes a lot easier. Why not alias ls="ls --some --options --you --like"? That is off course perfectly valid, im just used to having LS_OPTIONS from my own use of ls. AFAICT empty-string is a valid envvar value. What my real sh says A wrong assumption on my part il revert the change and add a switch to the unset command instead. Quote Link to post Share on other sites
grable 1 Posted April 24, 2015 Author Share Posted April 24, 2015 I added syntax highlighting version of /bin/edit.lua as /bin/cedit.lua. Its a bit on the slow side though, theres something about redrawing when scrolling that is rather inefficient Its not as fast as edit of course, there is a slight delay when redrawing after scrolling... but its very usable. Quote Link to post Share on other sites
dgelessus 26 Posted April 26, 2015 Share Posted April 26, 2015 I'll need to check out cedit, that sounds useful, even if it may be slow. Have you considered putting your code on GitHub? That would make it easier to keep track of changes and version history. It would also allow viewing the code in the browser (without needing to download the archive) and people could submit pull requests (suggested code changes or additions, such as bug fixes). Quote Link to post Share on other sites
grable 1 Posted April 26, 2015 Author Share Posted April 26, 2015 Im not a fan of git, but i realise thats what everyone uses nowdays so il bite the bullet I put the changed files up now at OpenOS-mods .. but maybe i should have used openos as a base? Oh btw, cedit needs the inverted blinking from /lib/term.lua if your going to try it out. Quote Link to post Share on other sites
grable 1 Posted April 27, 2015 Author Share Posted April 27, 2015 Ive abstracted out the highlighter to its own library now, so that other programs can use it. Fixed a few bugs in cedit regarding scrolling and added goto-line shortcut too. Allso added a syntax highlighter for the terminal called hl (it can behave like more with the -m switch) Quote Link to post Share on other sites