Dash acting up for unknown reason

1

I restarted my kubuntu machine - from the menu leave->restart if that matters. Normally my terminal windows are brought up automatically after a reboot but this time my prompt was wrong and a bunch of other bizarre things.

Now /bin/sh is a link to /bin/dash and dash seems to have been loaded but suddenly it is a lot dumber than it was before the reboot. Now it doesn't recognize what shopt is. When I try to dot execute my profile (. ~/.bash_profile) I get error like /bin/sh: 28: /etc/bash_completion: [[: not found. On the command line command completion does not work nor the up & down keys for command history.

I have not knowingly downloaded any packages that should have messed with this. Is there a valid reason why this should suddenly start happening.

Now I executed /bin/bash from the command lines of my terminals and all seems to be well but this does not explain what is wrong with dash. Also bash is allegedly heavier than dash and since I open 20 or so terminals I would like to avoid that overhead if it is true.

Thank you for any insights into this.

Newton Falls

Posted 2012-12-28T02:50:34.697

Reputation: 201

[[ is and has always been bash only. It's an internal command (unlike [, which is a binary). – Dennis – 2012-12-28T03:19:47.783

Dash is a lighter version of bash so I assume the same applies. There has been no changes to my system to account for the above - at least of which I am aware. – Newton Falls – 2012-12-28T03:21:43.910

1[[ works in bash and ksh, but not in dash. I've tested it on my system to verify. This presentation agrees. I'm not sure what changed on your system, but [[ cannot work with dash. The rest of your problems should be due to the fact that .bash_profile can't be sourced. – Dennis – 2012-12-28T03:27:54.323

Thank you. I don't know what happened. I may just change the /bin/sh link to point to bash and be done with it. – Newton Falls – 2012-12-28T03:39:03.033

My best guess is that this is what happened in the first place. Changing /etc/passwd is more stable and prevents non-interactive shells from using Bash by default (it is heavier, after all). – Dennis – 2012-12-28T03:42:16.470

Answers

2

You can't have been using dash all this time:

  • Dash cannot understand [[, since it's one of Bash's internal commands.

  • Dash does not support tab completion.

  • Dash does not support arrow keys (editing, history).

(Source)

The only possible explanation is that your default shell changed somehow. I obviously can't know how this happened, but I can only think of two ways:

  • Something edited /etc/passwd and replaced your default shell. That's highly unlikely.

  • You were accessing Bash through a symlink (most likely /bin/sh), and a recent update set the symlink to its default target.

While it is true that Bash is heavier than Dash, this shouldn't be a problem with terminals (what Bash is designed for).

However, non-interactive shells should still use Dash by default (which is why /bin/sh should point to Dash).

Dennis

Posted 2012-12-28T02:50:34.697

Reputation: 42 934