# What is your favorite shell.



## Alain De Vos (Oct 28, 2022)

A shell can be used interactively & non-interactively. But what is your favorite & why ?
I recently learned mksh, once you know vi-keys it's quiet ok.


----------



## Cthulhux (Oct 28, 2022)

After moving on from `tcsh` which has the big disadvantage of treating exclamation marks as commands even when configured otherwise (if anyone could guide me how to have “!!” in strings, like archive passwords, not mess with my history, please do!), my interactive shell is `rc` (with readline), because it does not get in my way. No quirky highlighting, no pseudo-intelligent (wrong) auto-completion, no integration of VCSs I don’t even use, a decent scripting language for (e.g.) performing commands on a list of files.

For scripting, I usually use `bosh` from the schily tools, because it aims to be 100% POSIX-compliant (= portable), but I really don’t write many shell scripts - the language is ugly and hard to maintain.


----------



## Alain De Vos (Oct 28, 2022)

Posix can be unreadable just like perl. But it's up to the writer to make it readable.


----------



## Voltaire (Oct 28, 2022)

Almquist shell https://en.wikipedia.org/wiki/Almquist_shell

It's very similar to Bash and it's much faster in performance.


----------



## VladiBG (Oct 28, 2022)

sh for the root account and csh for regular user.


----------



## rorgoroth (Oct 28, 2022)

For an interactive I like zsh just because it has some niceties (themes, completion, etc) that mean I don't have to hunt or research much of anything - I don't use any of the fancy scripts people add to it with all kinds of weird git stuff.

For scripting, wherever possible I just use plain sh (my dev env is using busybox sh, which I believe is the same or similar to to dash) but when things get a little complex I use bash, once that begins to get complex I start using python and once that begins to get complex I reconsider if what I am trying to do is worth it.

On freebsd I always used (t)csh although my zsh config and personal scripts that I use instead of aliases goes together so nicely now that I'd use zsh on freebsd for interactive shell.


----------



## mer (Oct 28, 2022)

been using tcsh for a heck of a long time on interactive sessions, sh/bash for programming.

As for a bang in tcsh/csh, escape it with a backslash.


----------



## bob2112 (Oct 28, 2022)

Voltaire said:


> Almquist shell https://en.wikipedia.org/wiki/Almquist_shell
> 
> It's very similar to Bash and it's much faster in performance.


Do you simply mean /bin/sh or a different version of that shell?


----------



## Voltaire (Oct 29, 2022)

bob2112 said:


> Do you simply mean /bin/sh or a different version of that shell?


It's FreeBSD's default shell I mean. I think it's /bin/sh 
For example, if I type neofetch, I get this output:
_Shell: *sh*_


----------



## dbdemon (Nov 28, 2022)

I'm a long-time GNU/Linux user, so I tend to use bash, also on FreeBSD.

Although, the login shell for my FreeBSD root account is /bin/sh. 

I don't mind at all writing relatively simple or short programs in shell script (bash), and I think that makes sense. But once it gets complicated or needing to talk to a database, I switch to python.


----------



## meine (Nov 28, 2022)

I use fish


----------



## BobSlacker (Nov 28, 2022)

In FBSD I use zsh as interactive shell and sh for scripts, when the script get to complicated I move to perl.
I also use oksh on OBSD and I like it (only on OBSD).


----------



## cracauer@ (Dec 2, 2022)

bash

Can't do zsh, which I would prefer for interactive functionality. But I have libraries of shell code fragments that I use both in scripts and interactively - and the syntax incompatibilities between Posix sh and zsh make that impossible.

I also find bash to be pretty bug free for a program of its size.


----------



## ralphbsz (Dec 3, 2022)

Bash. Because about 15 years ago, it was the default on the Linux machines that I didn't (want to) administer, available on all OSes, and it works fine. And on my FreeBSD machines, I can easily install it. Today, it's even the default login shell for root on my FreeBSD machine (I do keep alternate accounts with /bin/sh and tcsh around).

I hardly write significant shell scripts. If it gets to be bigger than 20 or 30 lines, it gets moved to Python or Perl.

I could switch to zsh; it would have advantages (I think MacOS likes it better), but for now bash works fine.


----------



## zirias@ (Dec 3, 2022)

IMHO, there's no reason at all to use anything else than what your OS provides as /bin/sh for scripting (and yes, if strictly sticking to POSIX/bourne with scripting isn't enough, you really might be better off to use some "real" scripting language instead).

Leaves interactive shells. So far, the thread shows more or less what I expected:

Some like `tcsh`, most likely because a C shell comes with BSD "by tradition" and tcsh offers some nice interactive features.
Some want POSIX/bourne compatibility, then the choice seems to be either `bash` or `zsh` (I personally prefer zsh...)
"Exotic" shells (like fish) are a minority


----------



## steps (Dec 3, 2022)

shells/fish all the way. Yes, even for root. But I admit that I'm currently playing arround with plain /bin/sh as my interactive shell. Just to see how viable it is. And yes, I could live with it. Would be nice to have, if the prompt wouldn't drop zero-sized escape sequences, so the prompt could have some color or newline.


----------



## kpedersen (Dec 3, 2022)

For FreeBSD I tend to use bash. It still does work surprisingly well for typical popular GNU software.

That said, the inevitable GNU and/or Linux bloat is starting to appear. It is almost unusable on many Linux distros because of autocomplete plugins calling into programs to find argument lists. Plus if a program is missing, it scans the package repo to ask to install it. These kind of "unexpected" plugins are pretty messy and slow, breaking workflow.


----------



## hruodr (Dec 3, 2022)

.


----------



## Minbari (Dec 3, 2022)

Z shell (Zsh) because and I'm using it from a long time (when Arch GNU/Linux init behaved like a BSD-style one) and old habits die hard, but for scripting I'm using sh(ash) to keep as POSIX compatible as I can.


----------



## avner (Dec 4, 2022)

Any tcsh gurus ( mer ) on this thread want to explain how the following loop works?


```
set v = `myfile.txt`
  set i = 1
  while ( $i < = $#v )
  echo $v[$i]
  @ i = $i + 1
  end
```

The outcome is to echo each line of the text file. Looks to me like it is creating an array and looping through the array index. In particular I can't find andyreference to what "$#v" means but it seems like it should represent the number of lines in the file.


----------



## mer (Dec 4, 2022)

Not sure if that's csh/tcsh syntax.
first the backticks on set v = typically mean "execute this command" and would set v to the output of the command.

if you change that line to:
set v = `cat myfile.txt`

Then it sets v to the contents of myfile.txt
Typically $# is "number of arguments, the $#v is "number of arguments in v"

If myfile.txt has:
one
two
three
four
five

it prints 5 lines

If it has:
one
two
three
four
five six seven

you get 7 because whitespace is the default delimiter.


----------



## Vull (Dec 4, 2022)

I just use whatever shell the OS vendor provides. Usually this is /bin/sh, which is also what I prefer for scripting. I figure the OS vendors know what they are doing. All these shell scripting languages are basically the same to me anyway.


----------



## avner (Dec 4, 2022)

mer said:


> Not sure if that's csh/tcsh syntax.
> first the backticks on set v = typically mean "execute this command" and would set v to the output of the command.
> 
> if you change that line to:
> ...


You are absolutely right. I forgot to include "cat" in `set v = `cat myfile.txt``. This loop strategy was recommended as a way to sequentially feed a list of arguments to a command from a text file and I have to say it worked very well. I am sure with a huge file there would be a risk of crashing due to slurping the whole file at once into memory as opposed to reading the file a line at a time as can be done in bash with readline. At that point probably a perl or python script would make more sense though.


----------



## avner (Dec 15, 2022)

Not sure if this is a tcsh thing or a find thing but the behavior was unexpected ( for me anyway ).


```
> cd /usr/ports
> find . -type d -name fish*
find: No match.
> find . -type d -name *fish*
find: No match.
> cd shells
> ls
../                                heirloom-sh/                       rc/
./                                 ibsh/                              rubygem-shellwords/
44bsd-csh/                         ion/                               rush/
Makefile                           jailkit/                           sash/
anongitssh/                        klish/                             scponly/
antibody/                          ksh-devel/                         starship/
ast-ksh/                           ksh/                               switchBashZsh/
bash-completion/                   ksh2020/                           tcsh_nls/
bash-static/                       ksh93/                             tcshrc/
bash/                              mksh/                              v7sh/
bashc/                             modernish/                         viewglob/
bicon/                             nologinmsg/                        vshnu/
bosh/                              nsh/                               wcd/
ch/                                ohmyzsh/                           xonsh/
dash/                              oksh/                              yash/
elvish/                            p5-Bash-Completion/                zsh-antigen/
envy/                              p5-Shell-Perl/                     zsh-autosuggestions/
es/                                p5-Term-Bash-Completion-Generator/ zsh-completions/
etsh/                              p5-Term-ShellUI/                   zsh-navigation-tools/
fd/                                pdksh/                             zsh-syntax-highlighting/
fish/                              pear-PHP_Shell/                    zsh/
git-prompt.zsh/                    psh/
```


----------



## cracauer@ (Dec 15, 2022)

avner said:


> Not sure if this is a tcsh thing or a find thing but the behavior was unexpected ( for me anyway ).
> 
> 
> ```
> ...



Shells react differently when a pathname wildcard matches nothing:
- some shells then pass the 'foo*' including the star to the called program
- some shells consider it an error and do not call the program

The latter behavior can be surprising but is arguably safer.


----------



## laurentis (Dec 15, 2022)

avner said:


> Not sure if this is a tcsh thing or a find thing but the behavior was unexpected ( for me anyway ).
> 
> 
> ```
> ...



You should put quotes around these regular expressions:


```
/usr/ports % find . -type d -name "*fish"
./news/newsfish
./misc/cuttlefish
./biology/jellyfish
./devel/py-babelfish
./devel/py-jellyfish
./devel/rubygem-cheffish
./sysutils/thefish
./sysutils/catfish
./irc/p5-POE-Component-IRC-Plugin-Blowfish
./irc/hexchat-fish
./irc/irssi-fish
./security/p5-Crypt-Twofish
./security/pear-Crypt_Blowfish
./security/p5-Crypt-Eksblowfish
./security/pear-Horde_Crypt_Blowfish
./security/p5-Crypt-Blowfish
./net/gofish
./shells/fish
./games/stockfish
./graphics/cuttlefish
./textproc/amberfish
./www/bluefish
./www/p5-WWW-Babelfish
./www/glassfish
./x11-wm/sawfish
```


----------



## ralphbsz (Dec 15, 2022)

laurentis said:


> You should put quotes around these regular expressions:


Not just for the reason that it makes the fish comment actually work.

Imagine what would happen if your current directory /usr/ports contained two files, one called tunafish and another called elephantfish. Now if you type your command "find . -type d -name *fish", what a shell will do to it is this: It will expand *fish, and issue the command "find . -type d -name tunafish elephantfish", and that is completely not going to work. Matter-of-fact, I think it will make find tell you about a syntax error in your command.

Lesson: If you use globs (* and ? and such) in your command line, in any place OTHER than commands that expect one or more file names, you have to escape or quote the glob characters. The find command is the most common place where this leads to errors.


----------



## Vull (Dec 15, 2022)

avner said:


> Not sure if this is a tcsh thing or a find thing but the behavior was unexpected ( for me anyway ).
> 
> 
> ```
> ...


find -type d | grep fish


----------



## Yampress (Dec 15, 2022)

zsh & csh  on FreeBSD
bash on linux


----------



## Argentum (Dec 15, 2022)

meine said:


> I use fish


Same here -  shells/fish.


----------

