What shell do you guys use? - BSD

Users browsing this thread: 1 Guest(s)
zge
Long time nixers
On the topic of shells, does anyone know how to get ksh's "horizontal line scrolling" feature in bash? That's really the only thing (except maybe for the cleanness of ksh) that I notice and prefer over bash. I keep on using bash because of it's superior auto-completion, though.
wolf
Members
(18-06-2020, 03:13 PM)jkl Wrote: I admit that I hadn’t tested it on a real Solaris yet, but wouldn’t pkgsrc work?

Probably would work. But I can't due to some company rules. But I'll try it on OpenIndiana.
phillbush
Long time nixers
(18-06-2020, 04:15 PM)zge Wrote: On the topic of shells, does anyone know how to get ksh's "horizontal line scrolling" feature in bash? That's really the only thing (except maybe for the cleanness of ksh) that I notice and prefer over bash. I keep on using bash because of it's superior auto-completion, though.

Put the following in your ~/.inputrc
Code:
set horizontal-scroll-mode on
eadwardus
Members
I use mksh as interactive shell, and rc/posix shell to write scripts. But for me, any shell with auto-completion serves its purpose as interactive shell, as i usually use it only to run commands.
zge
Long time nixers
(21-06-2020, 12:21 PM)phillbush Wrote:
(18-06-2020, 04:15 PM)zge Wrote: On the topic of shells, does anyone know how to get ksh's "horizontal line scrolling" feature in bash? That's really the only thing (except maybe for the cleanness of ksh) that I notice and prefer over bash. I keep on using bash because of it's superior auto-completion, though.

Put the following in your ~/.inputrc
Code:
set horizontal-scroll-mode on

For some reason that didn't work on my system, but

Code:
set horizontal-scroll-mode On

did. Not as nice as ksh, but it works well.
phillbush
Long time nixers
(08-07-2020, 08:16 AM)zge Wrote: For some reason that didn't work on my system, but

set horizontal-scroll-mode On

did. Not as nice as ksh, but it works well.

That's strange, the manual says:

Quote:Unrecognized variable names are ignored. When a variable value is read, empty or null values, "on" (case-insensitive), and "1" are equivalent to On. All other values are equivalent to Off.

Anyways...
One thing (other than <(command)) that makes me like bash more than ksh is that in ksh you can only rebind the keys in the emacs mode, you cannot rebind keys in the vi mode, while in bash you can rebind in both modes. Line editing in bash is much more involved.

That makes me think that shells should not be interactive, instead we should use a wrapper like rlwrap that does the interactive job of line editing and completion, leaving the command parsing and execution job for the shell itself. Thus, you could reuse the shell wrapper in other shells/prompts like debuggers and interpreters, and have a uniform interface for every shell. You could for example, use sh, plan9's rc and a lisp interpreter all with the same line editing keybindings.
jkl
Long time nixers
Don’t they all use readline anyway?
jkl
Long time nixers
Currently testing: The rather usable ion shell from Redox OS (seems to be rather resource-hungry in its default configuration though) and the desh which is a fork of the es shell with some additional interactivity, namely: a NIH alternative to libreadline.

Both are mostly undocumented. That’s fun.
injinj
Registered
(01-10-2020, 05:52 AM)jkl Wrote: Currently testing: The rather usable ion shell from Redox OS (seems to be rather resource-hungry in its default configuration though) and the desh which is a fork of the es shell with some additional interactivity, namely: a NIH alternative to libreadline.

Both are mostly undocumented. That’s fun.

I ran the loop test:

Code:
; cat > loop2.es <<XX
> echo 'echo -n x' > test.sh
> let (i = 1) {
>   while {$$i :le 100} {
>     desh test.sh
>     i = <={%sum $$i 1}
>   }
> }
> echo x
> exit 0
> XX
; time desh loop2.es                                                    
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
0.08user 0.05system 0:00.14elapsed 100%CPU (0avgtext+0avgdata 4052maxresident)k
0inputs+8outputs (0major+24063minor)pagefaults 0swaps
; bash
$ time (for i in $(seq 1 1 100); do bash test.sh ; done)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
real    0m0.080s
user    0m0.038s
sys     0m0.045s

Bash almost twice as fast.
jkl
Long time nixers
Ah, the dev. Welcome to nixers and thank you for contributing this!
injinj
Registered
I think that the missing shell in this discussion is Powershell. Powershell is like the SystemD for Windows, except with command line capabilities.
pyratebeard
Long time nixers
(01-10-2020, 05:48 PM)injinj Wrote: I think that the missing shell in this discussion is Powershell. Powershell is like the SystemD for Windows, except with command line capabilities.

"Aww, look at Windows trying to be a real operating system." - quote from an ex-colleague on Powershell

I could do with a shot of rum right now.
jkl
Long time nixers
The Powershell has an awful command line syntax, sadly.
injinj
Registered
I tried posh on Linux for a couple of days, but none of the plugins worked, they all required Windows. The problem with higher level languages on the command line is that a shell's main duty is to fork processes. Once the shell is forked, the only communication available are inter process through a pipe. All of the environment is no longer shared.

I was thinking about storing the environment in a sqlite db and sharing it across shell forks.

In es:

Code:
; let (i = 0) { fn hello {echo $i; i = <={%sum $i 1}}}
; hello ; hello ; hello
0 1 2

The closure variable i is incremented after every invocation of hello, but if hello in a subprocess, then i doesn't change:

Code:
; echo `{hello ; hello ; hello}                                        
3 4 5
; echo `{hello ; hello ; hello}                                        
3 4 5

The subshell fork of the backquote operator causes the variable i to be copied and manipulated in the subshell. The same happens with the env in bash when a subshell is spawned.

If the environment were persistent, that might allow for fancier command line multi processing. Maybe a new subshell operator, for example:

Code:
# normal subshell fork copy env
$ echo $(i=hello ; echo $i)
hello
# shared subshell fork share env
$ echo %(i=hello ; echo $i) ; echo $i
hello
hello
venam
Administrators
(02-10-2020, 06:54 AM)injinj Wrote: The closure variable i is incremented after every invocation of hello, but if hello in a subprocess, then i doesn't change:
Code:
; echo `{hello ; hello ; hello}                                        
3 4 5
; echo `{hello ; hello ; hello}                                        
3 4 5

I think the second example of subprocess is missing.
injinj
Registered
(02-10-2020, 06:56 AM)venam Wrote:
(02-10-2020, 06:54 AM)injinj Wrote: The closure variable i is incremented after every invocation of hello, but if hello in a subprocess, then i doesn't change:
Code:
; echo `{hello ; hello ; hello}                                        
3 4 5
; echo `{hello ; hello ; hello}                                        
3 4 5

I think the second example of subprocess is missing.

I could run the same echo command 100 times and it will still print 3 4 5. The reason is that the shell environment is forked, and then hello is run 3 times. I can capture this with ps like this:

Code:
; echo `{ps ax | grep desh > ps.out; hello ; hello ; hello} ; cat ps.out
3 4 5
5205 pts/0    Ss     0:00 -desh
17160 pts/0    S      0:00 -desh
17162 pts/0    S+     0:00 grep desh

; echo `{ps ax | grep desh > ps.out; hello ; hello ; hello} ; cat ps.out
3 4 5
5205 pts/0    Ss     0:00 -desh
17187 pts/0    S      0:00 -desh
17189 pts/0    S+     0:00 grep desh

The 5205 process is the desh running in the terminal connected to pts/0, the 17xxx process are subshells spawned using the backquote operator, these are running the hello functions.