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

learn more… | top users | synonyms

2
votes
1answer
32 views

shell script echo text name in for looping multiple texts

I am trying to do this text1="word1 word2 word3" text2="word4 word5" text1="word6 word7 word8" for var in $text1 $text2 $text3 do echo $var" in "(__?__) done expected output word1 in text1 ...
2
votes
1answer
67 views

Getting script's real absolute path in /bin/sh

I'm looking for a way to get the real absolute path to the current /bin/sh script. It should work for situations like this one: /path/to/symlink/in/PATH/somescript -> ../../Package/current/...
3
votes
2answers
53 views

Job control in dash

I don't understand the problem about which the standard shell in Debian (dash) complains: test@debian:~$ sh $ man ls ctrl+Z [1] + Stopped man ls $ jobs [1] + Stopped ...
3
votes
1answer
54 views

Why does bash 4.3 keep allocating memory in a script

Why does this shell script gradually consume more memory in bash? I’m not using any local variables and although the value of cpid is changing at every iteration because ls exits immediately, but it ...
1
vote
1answer
59 views

How can I access the history buffer in sh? (not in Bash)

Is there a command history in sh, for example how to access it, and as well, how to ensure it is clear? To clarify shells here: let's say you've logged on to a non-Gui Linux system, and $SHELL is ...
0
votes
0answers
36 views

How to freeze the dash bar in Gnome 3?

I'm on a freshly installed Debian 8.3 (Gnome 3.14) and I can't find if it is possible to display the dash bar permanently (as a dock on Mac OS X). The dash is hiding automatically... This looks like a ...
0
votes
2answers
30 views

Running source command with -x for debugging

I am trying to understand how a shell script is working. The tutorial states that the script should be run as the following way: source oe-init-build-env rpi-build Usually when doing this kind of ...
0
votes
1answer
38 views

Dash print expanded commands

Running xtrace or set -x with Bash will print the expanded command: $ bash -xc 'touch "alfa bravo"' + touch 'alfa bravo' However Dash does not print the command that is actually run: $ dash -xc '...
1
vote
1answer
150 views

Bash FUNCNAME equivalent in Dash

Bash can print the current function name: $ bash -c 'g(){ echo $FUNCNAME; }; g' g However Dash cannot use FUNCNAME: $ dash -c 'g(){ echo $FUNCNAME; }; g' It is possible to access the current ...
0
votes
3answers
74 views

DASH scripting errors: I don't think I know how to set up variables correctly

#!/bin/sh export $REG=0x000000 export $DONE=0x4A9FFF while $REG -le $DONE do (($REG+1)) printf 'wm8280_reg get 0x'$REG'\r\n' sleep 1 done This leads to the errors: ./...
1
vote
1answer
18 views

swap windows with dash script

I have written a bunch of dash scripts that resize and move windows for better efficiency. The structure is the following: i have a row of 8 windows that are stacked to the bottom of my screen, like ...
1
vote
2answers
109 views

Invoking a script with sudo ignores the shebang

Invoking a script using sudo ignores the shebang and runs the script in a different shell. To test, I created a script (test.sh) containing: #/bin/bash echo "BASH is: $BASH" echo "actual shell is: `...
3
votes
1answer
72 views

Why does kill not work from script, but does work from terminal?

I have the following contrived script to illustrate my issue: #!/bin/bash set -eux sudo sleep 120 & spid=$! sleep 1 sudo kill $spid wait $! This will print $ ./test.sh + spid=21931 + sleep 1 +...
2
votes
2answers
333 views

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 ...
2
votes
1answer
77 views

are there any other shells than bash/dash which are used used as default in GNU/Linux distros?

Debian/Ubuntu use bash/dash and while you can use and have access to other shells, they don't work well with the kernel, so for booting up purposes, you have to have bash/dash. Are there any other ...
3
votes
1answer
92 views

Export a selection of environment variables with correct escaping

I want to export some environment variables which I set in a dash script to a file: myvariable="line 1 LINE=3 some characters: # \" \$ line 5" myvariable2="abc" export myvariable myvariable2 ...
3
votes
1answer
77 views

Dash exec redirection error

This: set -x rm -f p; mkfifo p exec 99<>p succeeds in bash but fails ("99 not found") in dash. How do I get it to work in dash?
2
votes
2answers
130 views

DASH hexadecimal string comparison

I am attempting to compare two strings containing hexadecimal numbers in a dash test, one which has leading zeros and one which doesn't: hex_string_1: 0x02a0000b hex_string_2: 0x2a0000b Trying if [ ...
0
votes
2answers
130 views

How to run sh without reading ~/.profile?

With bash, for example, one can pass the --norc --noprofile flags to prevent the reading of shell initialization files. What's the equivalent for sh? If there isn't one for sh, is there at least one ...
-1
votes
1answer
123 views

What is Dash(-) actually in unix or linux? [duplicate]

It's been While since i'm using dash(-) in unix command. But have never found out what exactly is this. Have searched at some place it says . It mean stdin/stdout when used in end of command or like ...
3
votes
2answers
2k views

dash: parse string into two variables

I have a dash script, and I need to parse $1, which is a string containing two parts separated by ':', such as foo:123. I would like to to save foo in $X and 123 in $Y. I thought I could use read: $ ...
13
votes
6answers
748 views

/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
2
votes
1answer
215 views

I have a multi-line string that I need to iterate over, but I'm not using bash. Advice?

I'm using Dash because this is to run on my rPi. Bash is not an option. I'm rewriting a Bash script to work with Dash. I'm hoping to make it as POSIX-compliant (portable) as possible. The thing is it'...
-1
votes
1answer
874 views

Some commands not working in bash script

I'm using Ubuntu 14.04.02 32bit. On doing some shell programming, I found out that running the script through the sh command sometimes cause errors. Is it because the sh command is invoking the ...
3
votes
1answer
90 views

Trailing colons and dash's builtin test command

What's the meaning of a trailing colon to dash's builtin test (or [) command? I was surprised when I found that if [ ... ]: ; then .. ; fi works (at all) in dash, but not bash, and it seems to be ...
3
votes
2answers
332 views

Why alias inside function does not work?

See the code below: a()(alias x=echo\ hi;type x;alias;x);a I have an alias inside a function, I do not want to change the external environment (that is why I am using () instead of {}), even the ...
3
votes
1answer
257 views

Avoid backslash expansion with echo in dash

First create a file with this exact content: a\nb I named this file foo, if I run the following, it prints the exact content of the file: bash -c 'bar=$(cat foo);echo "$bar"' But if you run it ...
1
vote
2answers
1k views

Replace user shell from dash to bash [duplicate]

Everytime I use my terminal, I am always put into the dash shell instead of bash. Is there any way to change this even just for my user only? Tried apt-alternatives but setting the default shell can't ...
6
votes
3answers
609 views

Dash equivalent of self-redirection of script output

In Bash you can redirect all future stdout output of the currently running script. For example with this script, exec > >(logger -t my-awesome-script) echo 1 echo 2 echo 3 This will end up in ...
0
votes
3answers
617 views

Can dash replace bash as my default shell?

From what I read, dash can be made as a shell by using the command ~$ chsh shirish Password: Changing the login shell for shirish Enter the new value, or press ENTER for the default Login Shell ...
1
vote
0answers
24 views

history - bash, dash, zsh and .profile [duplicate]

For a long time I have been wondering about the existence of many shells in GNU/Linux. To make the question a bit focused I have used only three shells - bash, dash and zsh. From wikipedia articles ...
1
vote
1answer
631 views

Add autocompletion in dash

Is it possible to get at least "some" autocompletion in a dash shell like in bash? At least for the existing filenames in a path.
4
votes
1answer
438 views

create a dash prompt

When I log in to my server which has dash as default shell, I get a prompt that looks like this: \[\033[1;31m\]\u\[\033[0m\]@:\w # How can I configure the server that it shows something like this? ...
27
votes
3answers
6k views

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, ...
1
vote
1answer
2k views

'sh: 0: Can't open HoNClient-3.4.3.sh' when I try to run the HoNClient

I've been trying to install HoN on my laptop. It's running 32-bit Linux Mint 15. The problem I've run into is this: When I try to run the client in the terminal, using the command: sudo sh HoNClient-...
15
votes
1answer
713 views

Percent in $PATH environment variable

My $PATH looks like this: /home/torbjorr/deployed/vector/x86_64-GNU%2fLinux:/home/torbjorr/deployed/typewriter/x86_64-GNU%2fLinux:/home/torbjorr/deployed/mustudio/x86_64-GNU%2fLinux:/home/torbjorr/...
3
votes
1answer
152 views

Where do I place commands to automatically be exported for all users?

I have an embedded platform running an Arago linux distribution. Right now the only "user" is root but there will eventually be others, but I don't know how many or what user IDs they will have. ...
0
votes
1answer
1k views

Can I use an if statement to detect if bash and dash are being run interactively? [duplicate]

After looking around for a while I've found several good pages describing how to check and see if a bash script is running interactively and there seem to be several methods, but one of them that I ...
51
votes
5answers
5k views

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 ...
4
votes
3answers
302 views

dash reports 'Syntax error: “(” unexpected' when using process substitution

I have following bash command diff <(xzcat file1.xz) <(xzcat file2.xz) and I need to execute it in dash. On my system (Debian Wheezy), dash is the default interpreter for cron (/bin/sh is a ...
1
vote
1answer
694 views

Can't access command history in my shell (sh)

I'm not sure if readline is what really missing but the problem is shell (instead of bash) and when I click the up and down arrow I get the following instead of command history: $ ^[[A^[[A^[[A^[[A^[[...
3
votes
4answers
12k views

How to know which is the default script shell in Centos?

I'm using Centos 6 and after reading about different shells and dash implementasion as sh replacement in Debian, Ubuntu and Fedora, made up my mind to replace sh with dash as the script shell in ...
2
votes
1answer
64 views

What is happening when a script encounters an error in one of the commands?

I used alien to convert an RPM to a .deb. I did NOT use alien's script conversion; I'm converting by hand. Indeed, the script did barf on some non-compatible syntax. My question is NOT about how to ...
4
votes
2answers
3k views

Calling bash from sh (dash) with commands read from args, and “Unterminated quoted string”/“unexpected EOF”

Just thought I'd document this: I'm trying something very simple - set env variable in bash, and print it out: $ bash -c "a=1; echo a$a;" a $ bash -c "a=1; echo a\$a;" a1 Now I'd want this same ...
0
votes
3answers
944 views

Proper place to put shell prompt(PS1) when use sh/bash/zsh together

I'm using dash(sh) or bash or zsh. If possible, I would prefer to put in common place. I want to put proper PS1 settings when I interactive with shell, so these situation should be considered login ...
0
votes
1answer
1k views

Login script for bash not loading

I am very confused about the login script for bash. I have always used ~/.bash_profile to configure my bash shell. Now I am on a new system just as a user: I am not root. This system was originally ...
4
votes
2answers
2k views

Get line number in a Bourne shell script

I'd like to be able to print the current line number in a shell script. I know about the $LINENO variable in Bash shells, but it doesn't seem to exist in Bourne shells. Is there any other variable ...
10
votes
2answers
3k views

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....
5
votes
2answers
3k views

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. ...
9
votes
1answer
4k views

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? ...