Questions tagged [dash-shell]

A POSIX-compliant shell implementation that aims to be as small as possible. Please use the [hyphen] tag instead of [dash] if your question is about the "-" character.

The Debian Almquist shell (dash), a modern replacement for , is a POSIX-compliant Unix shell. It requires less disk space than , for example, but it is also less feature-rich.

Resources

151 questions
3
votes
1 answer

Bash : "done" unexpected (expecting "fi")

I get the following error when i try to run the script Bash : "done" unexpected (expecting "fi") I tried both bash and dash ,i get the same error. topip4="false" topip6="false" topurl="false" for par in "$@" ; do if [ "$par" == "-topip4" ] ;…
SteveL
  • 3,331
  • 4
  • 32
  • 57
3
votes
2 answers

Dash variable expansion does not work in some cases

This work is being done on a test virtualbox machine In my /root dir, i have created the following: "/root/foo" "/root/bar" "/root/i have multiple words" Here is the (relevant)code I currently have if [ ! -z "$BACKUP_EXCLUDE_LIST" ] then …
Kaurin
  • 294
  • 1
  • 3
  • 9
3
votes
3 answers

Is setting a Linux shell other than /bin/sh problematic?

My company is starting to grow our Linux support and some of our shell scripts are starting to get more complex. Today we use the shebang as #! /bin/sh but we are having problems with some distros like Ubuntu for example where sh points to dash…
Mac
  • 3,397
  • 3
  • 33
  • 58
3
votes
2 answers

In a shell script, how do I replace the first occurrence of a string, after a different string

I have a simple config file that looks a bit like this: [sectionA] url = value1 username = value2 password = value3 [sectionC] url = value1 username = value2 password = value3 [sectionB] url = value1 username = value2 password = value3 And I want…
Cylindric
  • 5,858
  • 5
  • 46
  • 68
2
votes
3 answers

What is the most efficient way to escape passed parameters in ssh on a posix compliant shell?

Sometimes you want to escape something reliably before passing it to a shell through ssh. It's curious how difficult this problem seems to be though. :-$ Is there a shorter or otherwise more efficient way of defining this function, so it works with…
j.l.
  • 195
  • 1
  • 1
  • 7
2
votes
1 answer

how to create a non-ascii file using redirection with `sh -c`?

The same command: echo 1 > filename creates different filenames: $ sh -c 'echo $LANG >=с=.sh' && ls *.sh | od -c 0000000 = 321 = . s h \n 0000007 and $ bash -c 'echo $LANG >=с=.bash' && ls *.bash | od -c 0000000 = 321 201 = . b …
jfs
  • 399,953
  • 195
  • 994
  • 1,670
2
votes
3 answers

Busybox sh won't execute the bash script

I have a small script called test.sh which prints the value based on the index given. #!/bin/sh days_in_month=(0 31 28 31 30 31 30 31 31 30 31 30 31) echo "${days_in_month[$1]}" The above code works fine if I execute using bash. $ bash test.sh…
NayabSD
  • 1,112
  • 2
  • 15
  • 26
2
votes
1 answer

echo prints "\n" differently between /bin/sh and /bin/bash

I have a shell script that reads a multi-line JSON string from cURL: r=$(curl -H "X-Vault-Token: $VAULT_TOKEN" -fs $VAULT_ADDR/v1/$1) If I run echo $r and execute the script with /bin/sh I see that newline characters inside the JSON are interpreted…
2
votes
3 answers

Shell conditional errors out - Bash syntax not recognized

I have a little shell script and cannot seem to figure out how to create a simple conditional statement. big_width=$(($width > 1700)) big_height=$(($height > 1700)) if [ $extension != "jpg" || $big_width || $big_height ]; then Gives the errors [:…
James L.
  • 12,893
  • 4
  • 49
  • 60
2
votes
1 answer

Exclude files and directories from find . function that match some regular expression

I am using Bash to go through some directories and files. I am using find function as shown in the example and I need to exclude all directories (and all it includes) and files which name match some regular expression (which can be anything). while…
Zeusko
  • 47
  • 1
  • 6
2
votes
0 answers

why doesn't dash grammar accept for loop with a non-empty linebreak grammar symbol - is this a dash bug?

Under dash shell, I see for foo >in dash: Syntax error: "in" unexpected (expecting "do") The POSIX shell grammar at http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02 has for_clause :(...) | For name…
Mark Galeck
  • 6,155
  • 1
  • 28
  • 55
2
votes
1 answer

LD_PRELOAD not applied to command given through system() in DASH, but working with BASH

I am using LD_PRELOAD, and I am seeing a difference between bash and dash when using the system() command. Let's consider this simple C program: #include #include #include #include #include…
Olivier
  • 19
  • 2
2
votes
1 answer

Why can "dash -c ':'" fail with dash 0.5.8 built from source?

With a dash binary compiled from source (version 0.5.8, available at http://gondor.apana.org.au/~herbert/dash/files/dash-0.5.8.tar.gz), executing dash -c ':' fails with dash: 1: :: Permission denied This means that constructs such as case foo…
fornwall
  • 2,877
  • 3
  • 25
  • 38
2
votes
1 answer

Strange dash arithmetics

Having the following: #!/usr/bin/env dash seq -w 10 | while read -r num do echo $num: $((num + 1)) done prints 01: 2 02: 3 03: 4 04: 5 05: 6 06: 7 07: 8 sd: 3: sd: Illegal number: 08 Can anyone explain what is the problem with above dash…
clt60
  • 62,119
  • 17
  • 107
  • 194
2
votes
3 answers

How to check in dash for root

The standard-solution for bash, see: https://askubuntu.com/questions/15853/how-can-a-script-check-if-its-being-run-as-root which is: #!/bin/bash if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi does not work in…
Robby75
  • 3,285
  • 6
  • 33
  • 52