[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    Re: Interactive /bin/sh
From:       rank1seeker () gmail ! com
Date:       2013-12-16 14:55:22
Message-ID: 20131216.145522.249.2 () DOMY-PC
[Download RAW message or body]

> An alternate viewpoint:  I would prefer that /bin/sh remain as lean and
> mean as possible, conforming to posix and especially NOT becoming
> bloated with interactive usability stuff.  If you want a user-friendly
> bourne shell and can afford the memory and cycle bloat, use bash. 
> 
> Please keep /bin/sh lightweight for embedded and dedicated-purpose
> systems that need a posix-conforming shell without a ton of overhead.

I'm against code-bloat. We are talking here about minimalistic interactive shell, \
which is compatible with base scripts. Scripting in [t]csh and just .cshrc, is a hell \
(and it basically aliases to 'sh' scripts which actually do the real work). I use it \
only because of interactivnes. I don't have many interactive needs and sh is just \
metting those.

Now, BEFORE any code is added, let see what do we have available ATM 9.2 RELEASE...

path completion => function which provides it, searches CURRENT dir
So, in order to implement command completion, we need to use SAME EXISTING function \
of path completion, in EACH dir specified in PATH variable + once this has been done, \
results can be buffered, as PATH's dir are static (upon port install, one would \
'rehash' which would need implementation)

There is even more useful EXITING but UNDOCUMENTED code:
http://svnweb.freebsd.org/base/head/bin/sh/parser.c?view=markup

I wanted current dir, to dinamically change in prompt whenever I 'cd' somwhere:
--
PS1=$PWD    # Won't work as it is static!
--

At above URL, looking at lines 1939-2002 where 'switch' resides:
--
# \h - local hostname
# \w - working dir (full path)
# \$ - becomes '$' for normal users, '#' for root
PS1="$USER@\h:\w \$ ";  export PS1
--
Now I have dinamic current dir in prompt. (I even colorized each part of prompt, but \
coloring code here would be too long and messy) I would just like another one \
\something, which would give last CMD's exit code, to be part of a prompt. Cost would \
be just 1 additional 'case' in above 'switch' statement


> After svn r244941 - which fixed a bug preventing ed-search-next-history
> and ed-search-prev-history from working - this should be possible. To
> bind them on "Page Up" and "Page Down":
> - bind "\e[5~" ed-search-prev-history
> - bind "\e[6~" ed-search-next-history

Looks like what I wanted to be implemented (Prefix-based history navigation), is \
already here. ;) It works slightly different then in [t]csh, that is, it matches \
string anywhere in history of command, while [t]csh's implementation only from \
begening. But it doesn't matter, I like it anyway. Just a few more key presses and \
occurance is narrowed enough.

> But as far as I know, even with those bindings /bin/sh is still missing
> a way to save the command history to disk and load it back at startup.

Well, to me it isn't so important, but it can be emulated for login shell via custom \
functions that are auto called upon login, via ~/.profile and ~/.shrc Upon logout:
    fc -ln > .sh_history
However, I don't know how to fill it back into builtin 'fc' at login ... :P


To sum up:
Just add path completion with rehash & last CMD's exit code for custom prompt.
History file, if others want.



Domagoj Smolčić
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic