Questions tagged [dash]

The Dash shell, a POSIX-compliant derivative of the Almquist shell used as /bin/sh in Debian, Ubuntu and other Linux distributions

Dash is a with POSIX features and little more. It is derived from the Almquist shell , originally to serve as /bin/sh on Debian, and also used in Ubuntu and other derivatives and other Linux distributions. Dash is smaller and faster than Bash , but has fewer features.

Use this tag if your question is specifically about Dash. If your question is about Bourne/POSIX shells in general, use .

168 questions
68
votes
7 answers

Is dash or some other shell "faster" than bash?

I always thought that the only benefit of using dash instead of bash was that dash was smaller, and therefore many instances of dash would start faster at boot time. But I have done some research, and found some people migrating all their scripts to…
admirabilis
  • 4,642
  • 9
  • 41
  • 57
54
votes
5 answers

Why does no one use the true Bourne shell as /bin/sh?

I've noticed that basically no system I've ever worked with has /bin/sh as a real executable. It's always a symlink to dash, bash in POSIX mode, or something similar. Why? What are the disadvantages of using the true, original /bin/sh? (Speed?…
strugee
  • 14,723
  • 17
  • 73
  • 119
28
votes
2 answers

Are dash, ash and sh script 100% compatible?

I wanted to know whether scripts written for dash, ash, and sh are 100% compatible? Are there any added features to dash or ash, or syntax change? From what I heard, ash is a direct descendant of sh.
user1115057
  • 795
  • 3
  • 12
  • 17
24
votes
4 answers

How to emulate Process Substitution in Dash?

In bash, I can use Process Substitution and treat output of a process as if it was a file saved on disk: $ echo <(ls) /dev/fd/63 $ ls -lAhF <(ls) lr-x------ 1 root root 64 Sep 17 12:55 /dev/fd/63 -> pipe:[1652825] unfortunately, Process…
Martin Vegter
  • 69
  • 66
  • 195
  • 326
23
votes
3 answers

Why don't my arrow keys work in sh?

I recently installed Ubuntu and when I run sh on the Terminal my arrow keys don't work so I can't go through my call history or edit whatever I'm typing. It just comes out as weird characters like ^[[A . The login shell is bash and it works fine but…
Joe
  • 231
  • 1
  • 2
  • 3
22
votes
1 answer

A couple arithmetic related commands, Dash, POSIX shell, sh, Increment

When pre/post incrementing a variable, in POSIX Shell, what is the difference between these two examples. They seem like they would have the same consequences, but would they be used differently? When would you prefer one over the…
J. M. Becker
  • 4,831
  • 3
  • 28
  • 40
17
votes
3 answers

What is the difference between : and true?

In bash: $ type : : is a shell builtin $ type true true is a shell builtin Looks like they are the same, but they don't give the same system trace: $ strace : strace: :: command not found $ strace true execve("/bin/true", ["true"], [/* 82 vars */])…
l0b0
  • 50,672
  • 41
  • 197
  • 360
16
votes
1 answer

Percent in $PATH environment variable

My $PATH looks like…
user877329
  • 721
  • 5
  • 22
14
votes
2 answers

Separate namespaces for functions and variables in POSIX shells

In dash, functions and variables appear to live in separate namespaces: fn(){ fn="hello world" } fn; echo "The value is $fn!" #prints: The value is hello world! fn; echo "The value is $fn!" #prints: The value is hello world! #the fn variable…
Petr Skocik
  • 28,176
  • 14
  • 81
  • 141
13
votes
2 answers

exit trap in dash vs ksh and bash

Here's a simple script that sets up a temp dir in the current dir and a trap to delete it on exit. #filename: script set -x trap 'rm -rf "$d"' exit d=`TMPDIR=$PWD mktemp -d` "$@" If I do ksh script sleep 100 or bash script sleep 100 and…
Petr Skocik
  • 28,176
  • 14
  • 81
  • 141
13
votes
7 answers

/bin/dash: check whether $1 is a number

What would be the best way to check whether $1 is an integer in /bin/dash ? In bash, I could do: [[ $1 =~ ^([0-9]+)$ ]] But that does not seem to be POSIX compliant and dash does not support that
Martin Vegter
  • 69
  • 66
  • 195
  • 326
11
votes
2 answers

Shell script returns 0 exit_status despite syntax error

Consider this script: #!/bin/sh foo=1 if [[ ! -z $foo ]]; then echo abc fi It's using the Bash syntax [[ ... ]] which doesn't work (as expected) when I run it with the default shell on Ubuntu (dash). However, its return code is still zero. $…
vitalstatistix
  • 223
  • 2
  • 5
11
votes
2 answers

When sh is a symlink to bash or dash, bash limits itself to POSIX-compliance, so it should be 100% compatible with sh?

From Difference between bash and sh: ABck to the question: If you have /bin/sh as a link to bash, then bash will not behave the same when called as /bin/sh as it does when called as /bin/bash. When called as sh, it will limit itself to mostly…
user1115057
  • 795
  • 3
  • 12
  • 17
11
votes
4 answers

Split string on colon in /bin/sh

My dash script takes a parameter in the form of hostname:port, i.e.: myhost:1234 Whereas port is optional, i.e.: myhost I need to read the host and port into separate variables. In the first case, I can do: HOST=${1%%:*} PORT=${1##*:} But that…
Martin Vegter
  • 69
  • 66
  • 195
  • 326
9
votes
1 answer

Error sh: 1: read: arg count

I want to simply wait for the user to acknowledge a message by pressing Return. In bash, I am able to call $ read $ However, in sh (dash in my case), I get $ read sh: 1: read: arg count $ It seems like I must provide an argument? Where does…
finefoot
  • 2,940
  • 2
  • 21
  • 41
1
2 3
11 12