Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
grable

Small changes to OpenOS

Recommended Posts

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.

Link to post
Share on other sites
  • 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." :)

Link to post
Share on other sites
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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

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).

Link to post
Share on other sites

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)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.