recent shell efforts

well, the foundation has been laid down for the next phase of tpsh development. Branch ‘parserlexer’ is basically setup to deal with the changes in tpsh_parse, tpsh_lex, and the switch from singular command line execution to enqueued command execution.

The new quote handling is actually quite a bit better, if buggy for now. The sh_eval() functions mostly become dead weight; coupled with the behaviour changes in tpsh_{parse,lex} behaviour the source, ., and eval built-ins (and anything relaying on them) are temporarily broken; as is tpsh -c ‘cmdstr’ until things are further integrated. Pipes also no longer work, since the command resolution doesn’t know how to deal with the command queue yet lol. Fixing 1 subroutine should will fix most breakages.

The idea is more or less that a command like

$EDITOR -o f1 f2 f3; cat f1 f2 f3 | sort -args | sed 's/x/y/g' > /tmp/q

becomes this:

     ( ['vim', '-o', 'f1', 'f2', 'f3'],
['cat', 'f1', 'f2', 'f3, '|'],
['sort', ',-args', '|'],
['sed', 's/x/y/g', '>', '/tmp/q'] )

and the trailing ‘|’ symbols would be used to indicate that the current element should be joined with the next (in a non technical sense that is) until the end of pipes is reached; recreating the pipeline (in so far as what happens).

The line is parsed into tokens, then analyzed and formed into a more interesting set of elements like the above array of array references; where the array refs are the argument vector (argv) of the commands to be passed onto pexec() or other suitable function. Previously the line was just parsed and dropped onto resolve_cmd() to figure out if it’s a pipe based, i/o redirection based, built-in, or external command; based on the scalar line or argument vector resulting from expansions.

the master branch remains the stable line for now until this topic branch is finished with.

I really have to take breaks more often…. usually a decent coding session lasts at least 6-8 hours or more. When you can’t remember the ficken function is reentrent and called multiple times, ya know it’s time to take a walk.

It’s been a pretty good day so far. Got stuck getting up early for a shopping trip, but hey at least I got some doughnuts out of the deal lol. Oy, I’m going to end up doing press ups more often 8=). Two bags of powdered doughntus my absolute favorite xD.

Ducked into Proving Grounds #1, and joined Spawn, Ez, Hostile, and a few pubs for some games. Man, it’s been insane today in the servers. Those I don’t give a crap if I hit anything, it’s time to empty the magazine kind of moments – like a bad zombie flick, swarms of tangos out for blood. After a bit of a break to work on tpsh, I ended up in Proving Grounds #3 with Duke and a couple others joined: but still groups 3-5 tangos haunting the halls. Well actually that’s not to bad, in RvS it was more like 4-7 tangos at a time… hehe. One odd thing, this time out in SWAT 4, I got stuck in the heavy plates. Normally I hate body armour that restricts movement, especially in games like SWAT where heavy armour slows you down, and doesn’t stop a patato gun, let along bullets. I think the suspects must’ve gotten scared — last man standing, and feeling like a land battleship, but surviving without injury ;-).

tpsh gained the sh derived `tpsh -c “commands”` behaviour today. Command completion and history features have evolved quite nicely. Really what needs working on is the shells lexical analysis. I figure for setting it up as my login shell, I’ll compile a small C program that sets up PERL_RL to load a suitable Term::ReadLine backend before exec’ing tpsh.

All in all, not a bad day; but not very furfilling either :-/

Writer’s Block: Prison Time

If you were sent to prison for an undefined amount of time, what would you miss most?

Live Journals Writer’s Block

Probably programming!

Honestly, I can’t fathom what it would be like to not program stuff…. if I didn’t have a computer or something, you’d probably find me rewiring old electronic gizmo’s into something new and strange, or building a robot…. or accidentally electrocuting myself in the process lol.

(that being said, if I had the resources I would try building my own PDA, and probably have to watch the FCC confiscate it or something :-(.)

bookmark: cmp nasm gas

http://www.ibm.com/developerworks/linux/library/l-gas-nasm.html

last line read: NASM uses the resb, resw, and resd keywords to allocated byte, word, and dword space in the BSS section.

(back in dec/jan or so, I was trying to learn some asm using examples in GAS and the NASM manual; wish I had time to restart those studies!)

Code monkey go to bed…

It’s been a rather slow day, but somewhat productive (only about 10 or 11 commits :@). My families made sure that I’ve had a throbbing headache most of the day… rat fuckers! But at least there is some work to show for it. tpsh now has a concept of $PATHEXT based on cmd.exe’s %PathExt% variable.

Windows is ruled by file extensions, while UNIX could care less about them; so really one of the few good things about Microsoft’s cmd.exe is you can tell it what file extensions should be “understood”, i.e. so you can type ‘notepad’ instead of ‘notepad.exe’. Since tpsh is modeled after the standard Unix sh, it’s mostly oblivious to file extensions: it cares about names. However it is virtually _impossible_ to use Windows from the CLI level without implementing something like PATHEXT or typing yourself into a nightmare (winxp/cmd.exe is actually good at making you do that, compared to a unix/sh).

For better compatibility with a Windows environment, tpsh now implements it’s (my) own concept of the feature, complete with a ‘pathext’ option (default on) to toggle the functionality. The main reason tpsh does this, is so I can type ‘gvim’ when I mean ‘C:Pathtogvim.bat’, the fact that I’m used to typing ‘vim’ is aside the point lol. (I rarely use gvim off win32 b/c of diffs between nt and unix cli)

About the only time I use file extensions is when forced (Win32), when ideal (.zip, .tar, etc), when saving text with CRLF for new line indicators (notepad friendly .txt), multimedia files (.png, .ogg, etc), or when deploying crap to a Windows machine lol. So it’s not an important thing for me; just a time saver.

Another thing I sorted out is what I call the “hash separator” for environment variables. UNIX shells by convention separate values like $PATH with a ‘:’, e.g. ‘/bin:/usr/bin’, but DOS and related bastards use ‘;’ for things like %PATH%, e.g. ‘C:Windows;C:WindowsSystem32’. Because many older operating systems use a ‘letter:path’ style for paths anyway, there is no universally portable default setting. Since virtually all operations involving a variables like PATH, CDPATH, and ENV (an extension used in tpsh, which I’ve never seen another shell use) involve a hash table, I call the mark the ‘hash-sep’ for short. One of today’s changes was exposing the hash-sep directly to the user.

The default hash-sep is ‘;’ under MSWin32, DOS, and OS/2 and ‘:’ otherwise, I’ve no clue what the hell VMS uses and don’t have access to it, so no worries yet ;-). Whenever the user changes the HASHSEP environment variable, the next time an operation that relies on it (basically hsplit(), short for hash-sep split()) the shell compiles it down to a suitable regular expression to save time on future commands.

setenv HASHSEP '/'
rehash

the rehash will cause ‘/’ to compile via qr for to speed up later splits; and due to the change of hashsep, causes the internal cache of $PATH to switch from the default ‘:’ or ‘;’, to ‘/’, which is probably not something anyone wants to do, but being able to fiddle with it can be useful for scripting reasons ^_^. Not to mention the fact that it makes concatenating things like PATH/CDPATH settings more portable when the environment requires something different.

Another bit of today’s work, was setting it up so that the history built-in now displays the correct line numbers. I want to setup builtins to save/load data from HISTFILE; so that command history is not lost between sessions – I’ve always had a bit of an itch about how most shells deal with it; wonder what tpsh might do hehe. Not sure about the $LINENO yet, I never really use it in scripting or interactive usage that much: will probably take the single unix specification into consideration on $LINENO.

If I didn’t have to so much crap for tomorrow, I could probably have half the manual done tonight and still get to bed before 0600 local. But no…. work early, work long, to be driven nuts after work, and probably end up PTFO instead of coding the night way.


*sigh*.

my idea of a great vacation: a Ferrari, laptops, solar panels to power them, hot date, and a tropical island with a sunny beach 😉