From owner-freebsd-questions@FreeBSD.ORG Thu Jun 10 17:19:56 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CAF6A106566C for ; Thu, 10 Jun 2010 17:19:56 +0000 (UTC) (envelope-from dan@more.net) Received: from vortex.more.net (vortex.more.net [198.209.253.169]) by mx1.freebsd.org (Postfix) with ESMTP id A923F8FC08 for ; Thu, 10 Jun 2010 17:19:56 +0000 (UTC) Received: from jane.spg.more.net (jane.spg.more.net [207.160.133.140]) by vortex.more.net (Postfix) with ESMTP id D856928424 for ; Thu, 10 Jun 2010 12:19:55 -0500 (CDT) Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by jane.spg.more.net (Postfix) with ESMTP id C6C2A2C64C for ; Thu, 10 Jun 2010 12:19:55 -0500 (CDT) From: Dan D Niles To: freebsd-questions@freebsd.org Content-Type: text/plain; charset="UTF-8" Date: Thu, 10 Jun 2010 12:19:55 -0500 Message-Id: <1276190395.5437.53.camel@jane.spg.more.net> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 Content-Transfer-Encoding: 8bit Subject: Switched to Bash and Comparison of Shells X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2010 17:19:56 -0000 I had been using csh/tcsh for 20 years and I just switched to bash. The recent discussion about the differences between the shells prompted me to take another look at bash. I thought I'd share my perception of the differences between tcsh and bash. The big thing tcsh is lacking, and the reason I switched, is the lack of sensible redirection (as some call it). Specifically, not being able to do 'command 2>/dev/null >/somefile' is why I switched. The which command functions differently between bash and tcsh. For example, I have ls aliased to do color output and add some other options that I like. With tcsh, 'which ls' returns "ls: aliased to \ls -GFB"; with bash it returns "/bin/ls". The tcsh behavior tells you what will be executed when you run ls. The bash behavior can be achieved in tcsh with 'which \ls', so I think I like the tcsh behavior better. I could probably write a function in bash that emulates tcsh's builtin which command. The alias mechanism in bash lacks the ability to do parameter substitutions like tcsh can. You can achieve the same thing with bash functions. The disadvantage of this is it doesn't show up in the aliases list. I worked around this by adding aliases for the functions too (because of the which behavior). The advantage of using bash's functions is you can do more complex things. With bash-completions installed, the two shells both do completions well. Bash lacks the "enhance" mode of tcsh that "considers periods, hyphens and underscores (‘.’, ‘-’ and ‘_’) to be word separators and hyphens and underscores to be equivalent." Both can do case insensitive completions. Bash completions do remote file completion, a feature I longed for in tcsh. There are some bugs in the bash-completions code, mostly due to its age. For example, the _rsync function still has the default shell as rsh and remote file completion does not work. I think tcsh completions are a little easier to set up, but you can do more with bash completions. Those are the big differences that I've noticed so far. All in all, the transition has been fairly easy. I hope someone will find my observations useful. Dan