What shell do you guys use? - BSD

Users browsing this thread: 2 Guest(s)
jkl
Long time nixers
A late update:

jkl Wrote:ksh93 everywhere because of POSIX.

I have actively decided to use different shells for scripting and interactive use for quite a while now and I have come to the conclusion that standard compliance does not matter for the latter at all. My shell scripts usually point to the bosh wherever I can compile it so I can be sure that they are relatively portable to anything that implements POSIX, just in case.

Interactive shells are a different thing though. The maximum "scripting" I do without writing a complete script file is looping over a set of files, so the scripting language is neglegible. The more important feature is the ability to find stuff in my history. One of the longest non-scriptable command lists which I regularly need consists of six commands and has different parameters towards the end, so finding it easily after a week of doing other shell work would be a good thing.

As I found myself using a different shell on almost all of my (non-Windows) machines, I am currently re-evaluating my options. macOS uses the zsh by default now, and as I spend more and more time on macOS, I gave it another try only to find that it is quite annoying to use as it tries to be smart and it really should not. I tried the ksh2020 today, but it is really the opposite of stable just yet. Too bad!

My preferred shell should
  • draw in as little additional dependencies as possible,
  • be a suitable interactive shell, i.e. not optimized for pure non-interactive use (sorry, bosh and rc!),
  • have acceptable globbing, tab-completion and history functionalities,
  • have a relatively fast startup time and a low resource usage (sorry, zsh and PowerShell!),
  • be in a mature state, not a "technical preview" anymore (sorry, nushell!),
  • come without any VCS integration out of the box or make it easy to get rid of that (showing your repository state is not a shell prompt's job in my opinion),
  • generally be configurable in a way that does not piss me off while using it,
  • be portable so I won't have to think about which shell I use every time I ssh into a different non-Windows system.

After checking the usual repositories and playing with some of them for a while, I narrowed down my selection a bit. I even included shells which I actively disliked for non-technical reasons before.

Code:
shells=( tcsh bash mksh fish ksh93 ) 

I did all of my tests in a Debian Unstable bash on Windows 10, the performance tests were done without changing any of the distribution's defaults; I temporarily renamed the .bashrc file though, so I could start from scratch.


1. Performance and resource usage

Code:
echo "echo x" > test.sh
for sh in ${shells[*]}; do
    printf "$sh: "
    time (for i in $(seq 1 1 100); do $sh test.sh; done)
    echo
done

Results:

Code:
tcsh: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
real    0m11.453s
user    0m1.156s
sys     0m3.781s

bash: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
real    0m3.075s
user    0m0.094s
sys     0m0.766s

mksh: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
real    0m5.452s
user    0m0.078s
sys     0m1.000s

fish: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
real    0m5.796s
user    0m0.406s
sys     0m1.219s

ksh93: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
real    0m2.823s
user    0m0.094s
sys     0m0.859s

Interesting: The tcsh is roughly twice as slow as the penultimate runner, and the ksh93 even outperforms the "native" bash. What about the resource usage? I opened all shells with a $sh -c sleep 1d & and checked the vsz= output:

Code:
tcsh:   14456
bash:   13316
mksh:   13316   # I had to specify "/bin/sleep" for that, ugh
fish:   93336   # lol what
ksh93:  16440

As you might imagine, this was my moment of getting rid of the fish shell again. I mean, wtf? The mksh's sleep weirdness will be ignored by me though. I hardly ever need an interactive "don't do anything for a while" command under most circumstances.

Let's give the other shells a spin.


2. Real-life test

For the real-life test, I did (of course) modify at least some of the defaults.

2.1. tcsh

I know, I know: The tcsh is bad for scripting and its syntax is a mess etc. etc. - hooray for the shebang, I guess. I configured some of it:

Code:
set prompt = '[%~]$ '
set autolist                # Tab completion list
set complete = enhance      # Case-insensitivity for the latter

bindkey "^R" i-search-back

Globbing: cd */*oo* moves into "shelltest/Foo".
Tab-completion: cd sh<tab>f<tab> moves into "shelltest/Foo". Good.
History:
- Ctrl+R sh<Enter> performs cd shelltest/Foo.
- !! brings back the previous command.
- !-3 brings back whatever was three commands ago.
Dependencies (on Debian Linux): libc, libtinfo.

2.2. bash

A similar basic configuration:

Code:
PS1='[\w]$ '
bind 'set completion-ignore-case on'   # Case-insensitivity for the tab completion

Globbing: cd */*oo* moves into "shelltest/Foo".
Tab-completion: cd sh<tab>f<tab> moves into "shelltest/Foo". Good.
History:
- Ctrl+R sh<Enter> performs cd shelltest/Foo out of the box - no configuration needed.
- !! brings back the previous command.
- !-3 brings back whatever was three commands ago.
Dependencies (on Debian Linux): libc, libtinfo, base-files, debianutils.

2.3. mksh

Again, I try to bring this shell to the same level as the others in my small test:

Code:
PS1='[$PWD]\$ '

Globbing: cd */*oo* moves into "shelltest/Foo".
Tab-completion: cd sh<tab>f<tab> fails. Case-insensitivity is not in mksh.
History:
- Ctrl+R sh<Enter> performs cd shelltest/Foo out of the box - no configuration needed.
- fc -s -- -1 brings back the previous command (no built-in shortcut).
- fc -s -- -3 brings back whatever was three commands ago (no built-in shortcut).
Dependencies (on Debian Linux): libc. Nice.

2.4. ksh93

It is safe to assume that most of what occurs with the mksh was directly or indirectly taken from the ksh... or was it? At least the completion commands need to be set up first:

Code:
PS1='[$PWD]\$ '
set -o emacs

Globbing: cd */*oo* moves into "shelltest/Foo".
Tab-completion: cd sh<tab>f<tab> fails. Again, there seems to be no built-in way to circumvent this which does not involve writing my own cd command.
History:
- Ctrl+R sh<Enter><Enter> - yes, that's twice - performs cd shelltest/Foo out of the box - no configuration needed.
- fc -s -- -1 brings back the previous command (no built-in shortcut).
- fc -s -- -3 brings back whatever was three commands ago (no built-in shortcut).
Dependencies (on Debian Linux): libc, binfmt-support.

3. Conclusion

I'll move on to the tcsh over the following weeks.

4. Afterword

... sorry, this has become somewhat longer than I had planned, again. You are happily invited to not have read it because of that. (All later edits were grammar fixes.)

--
<mort> choosing a terrible license just to be spiteful towards others is possibly the most tux0r thing I've ever seen


Messages In This Thread
RE: What shell do you guys use? - by smlb - 30-07-2014, 12:10 PM
RE: What shell do you guys use? - by eye - 30-07-2014, 12:12 PM
RE: What shell do you guys use? - by kirby - 30-07-2014, 07:22 PM
RE: What shell do you guys use? - by dcli - 30-07-2014, 08:42 PM
RE: What shell do you guys use? - by casscode - 31-07-2014, 06:40 AM
RE: What shell do you guys use? - by shtols - 31-07-2014, 11:08 AM
RE: What shell do you guys use? - by dcli - 31-07-2014, 01:16 PM
RE: What shell do you guys use? - by z3bra - 31-07-2014, 07:16 PM
RE: What shell do you guys use? - by jobss - 10-10-2014, 08:41 AM
RE: What shell do you guys use? - by xero - 10-10-2014, 10:57 AM
RE: What shell do you guys use? - by nopc0de - 11-10-2014, 01:58 PM
RE: What shell do you guys use? - by b4dtR1p - 12-10-2014, 09:15 AM
RE: What shell do you guys use? - by projektile - 13-10-2014, 03:13 AM
RE: What shell do you guys use? - by dcat - 13-10-2014, 09:40 AM
RE: What shell do you guys use? - by venam - 13-10-2014, 10:29 AM
RE: What shell do you guys use? - by z3bra - 13-10-2014, 01:01 PM
RE: What shell do you guys use? - by nrmc.dubz - 13-10-2014, 08:41 PM
RE: What shell do you guys use? - by delucks - 17-10-2014, 01:10 PM
RE: What shell do you guys use? - by sodaphish - 29-10-2014, 11:14 PM
RE: What shell do you guys use? - by exp0sure - 31-10-2014, 04:27 PM
RE: What shell do you guys use? - by rwzy - 07-11-2014, 01:41 AM
RE: What shell do you guys use? - by kaludis - 21-01-2015, 08:05 PM
RE: What shell do you guys use? - by cadav3rous - 23-04-2017, 02:48 AM
RE: What shell do you guys use? - by Mafia - 23-04-2017, 04:06 AM
RE: What shell do you guys use? - by rocx - 23-04-2017, 11:33 AM
RE: What shell do you guys use? - by Tmplt - 23-04-2017, 12:11 PM
RE: What shell do you guys use? - by jkl - 23-04-2017, 01:52 PM
RE: What shell do you guys use? - by robotchaos - 23-04-2017, 05:49 PM
RE: What shell do you guys use? - by r4ndom - 24-04-2017, 06:22 AM
RE: What shell do you guys use? - by evbo - 24-04-2017, 12:24 PM
RE: What shell do you guys use? - by jvarg - 24-04-2017, 01:51 PM
RE: What shell do you guys use? - by robotchaos - 24-04-2017, 02:33 PM
RE: What shell do you guys use? - by jvarg - 25-04-2017, 04:00 AM
RE: What shell do you guys use? - by r4ndom - 25-04-2017, 05:54 AM
RE: What shell do you guys use? - by z3bra - 25-04-2017, 06:11 AM
RE: What shell do you guys use? - by venam - 25-04-2017, 06:25 AM
RE: What shell do you guys use? - by robotchaos - 25-04-2017, 12:59 PM
RE: What shell do you guys use? - by rocx - 25-04-2017, 03:27 PM
RE: What shell do you guys use? - by robotchaos - 25-04-2017, 03:34 PM
RE: What shell do you guys use? - by dragomir - 25-04-2017, 05:49 PM
RE: What shell do you guys use? - by drkhsh - 28-04-2017, 07:38 PM
RE: What shell do you guys use? - by jkl - 02-06-2020, 09:37 AM
RE: What shell do you guys use? - by z3bra - 02-06-2020, 10:06 AM
RE: What shell do you guys use? - by jkl - 02-06-2020, 10:22 AM
RE: What shell do you guys use? - by twee - 02-06-2020, 06:57 PM
RE: What shell do you guys use? - by jkl - 03-06-2020, 01:44 AM
RE: What shell do you guys use? - by twee - 03-06-2020, 06:47 AM
RE: What shell do you guys use? - by jkl - 03-06-2020, 06:51 AM
RE: What shell do you guys use? - by wolf - 06-06-2020, 10:38 AM
RE: What shell do you guys use? - by jkl - 06-06-2020, 10:48 AM
RE: What shell do you guys use? - by ckester - 06-06-2020, 12:31 PM
RE: What shell do you guys use? - by wolf - 06-06-2020, 01:23 PM
RE: What shell do you guys use? - by jkl - 06-06-2020, 04:01 PM
RE: What shell do you guys use? - by twee - 06-06-2020, 05:15 PM
RE: What shell do you guys use? - by banna - 11-06-2020, 01:24 AM
RE: What shell do you guys use? - by seninha - 14-06-2020, 09:54 AM
RE: What shell do you guys use? - by wolf - 18-06-2020, 03:08 PM
RE: What shell do you guys use? - by wolf - 18-06-2020, 03:10 PM
RE: What shell do you guys use? - by jkl - 18-06-2020, 03:13 PM
RE: What shell do you guys use? - by pkal - 18-06-2020, 04:15 PM
RE: What shell do you guys use? - by wolf - 18-06-2020, 04:45 PM
RE: What shell do you guys use? - by seninha - 21-06-2020, 12:21 PM
RE: What shell do you guys use? - by eadwardus - 05-07-2020, 03:08 PM
RE: What shell do you guys use? - by pkal - 08-07-2020, 08:16 AM
RE: What shell do you guys use? - by seninha - 08-07-2020, 09:14 PM
RE: What shell do you guys use? - by jkl - 09-07-2020, 01:50 AM
RE: What shell do you guys use? - by jkl - 01-10-2020, 05:52 AM
RE: What shell do you guys use? - by injinj - 01-10-2020, 07:19 AM
RE: What shell do you guys use? - by jkl - 01-10-2020, 08:44 AM
RE: What shell do you guys use? - by injinj - 01-10-2020, 05:48 PM
RE: What shell do you guys use? - by pyratebeard - 02-10-2020, 06:11 AM
RE: What shell do you guys use? - by jkl - 02-10-2020, 06:27 AM
RE: What shell do you guys use? - by injinj - 02-10-2020, 06:54 AM
RE: What shell do you guys use? - by venam - 02-10-2020, 06:56 AM
RE: What shell do you guys use? - by injinj - 02-10-2020, 12:46 PM
RE: What shell do you guys use? - by ols - 15-11-2020, 04:30 PM
RE: What shell do you guys use? - by jkl - 15-11-2020, 05:47 PM
RE: What shell do you guys use? - by ols - 15-11-2020, 06:20 PM
RE: What shell do you guys use? - by mattrose - 15-11-2020, 09:40 PM
RE: What shell do you guys use? - by yakumo.izuru - 23-04-2022, 07:11 PM
RE: What shell do you guys use? - by Shrek - 24-04-2022, 11:22 AM
RE: What shell do you guys use? - by ckester - 24-04-2022, 03:35 PM
RE: What shell do you guys use? - by jkl - 27-04-2022, 05:02 AM
RE: What shell do you guys use? - by jkl - 12-09-2022, 12:34 PM
RE: What shell do you guys use? - by josuah - 16-09-2022, 07:54 AM
RE: What shell do you guys use? - by josuah - 16-09-2022, 08:10 AM
RE: What shell do you guys use? - by jkl - 16-09-2022, 11:57 AM
RE: What shell do you guys use? - by seninha - 16-09-2022, 07:23 PM
RE: What shell do you guys use? - by tool - 27-09-2022, 08:01 AM
RE: What shell do you guys use? - by jkl - 27-03-2023, 06:35 PM
RE: What shell do you guys use? - by seninha - 29-03-2023, 04:45 AM
RE: What shell do you guys use? - by jkl - 07-04-2023, 07:57 PM
RE: What shell do you guys use? - by jkl - 11-06-2023, 08:57 PM
RE: What shell do you guys use? - by rocx - 12-06-2023, 03:41 PM
RE: What shell do you guys use? - by jkl - 12-06-2023, 05:30 PM
RE: What shell do you guys use? - by rocx - 19-06-2023, 07:14 PM
RE: What shell do you guys use? - by x0ba - 08-08-2023, 02:31 AM
RE: What shell do you guys use? - by Dworin - 26-08-2023, 06:47 AM
RE: What shell do you guys use? - by jkl - 04-09-2023, 02:46 PM
RE: What shell do you guys use? - by Dworin - 09-09-2023, 11:21 AM
RE: What shell do you guys use? - by jkl - 09-09-2023, 01:52 PM
RE: What shell do you guys use? - by Dworin - 11-09-2023, 05:38 AM
RE: What shell do you guys use? - by z3bra - 12-09-2023, 12:49 PM
RE: What shell do you guys use? - by santafe - 12-09-2023, 03:43 PM
RE: What shell do you guys use? - by jkl - 13-09-2023, 11:35 AM
RE: What shell do you guys use? - by santafe - 13-09-2023, 04:37 PM
RE: What shell do you guys use? - by jkl - 13-09-2023, 06:18 PM
RE: What shell do you guys use? - by ckester - 14-09-2023, 12:07 AM
RE: What shell do you guys use? - by rocx - 16-09-2023, 03:23 PM
RE: What shell do you guys use? - by ckester - 16-09-2023, 09:56 PM
RE: What shell do you guys use? - by venam - 17-09-2023, 01:32 AM
RE: What shell do you guys use? - by ckester - 18-09-2023, 02:21 PM
RE: What shell do you guys use? - by jkl - 18-09-2023, 04:30 PM
RE: What shell do you guys use? - by ckester - 18-09-2023, 06:00 PM