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

Filter by
Sorted by
Tagged with
0 votes
0 answers
22 views

ffmpeg dash playback stream ends to early

I am trying to play back a dash manifest using ffmpeg but I keep running into the issue of ffmpeg ending with the error [http @ 0x671e580] Stream ends prematurely at 2250, should be ...
user avatar
1 vote
1 answer
46 views

Bash for every x files create sub folder and move files there

I am looking for an alternative dash command I can use as I am trying to execute the code from within python and due to the fact that the sub folder has 100's of files I am am trying to group into ...
user avatar
0 votes
0 answers
19 views

how to close file descriptor bigger then 9 by dash in shell script

I want launch a shell script in code called system("sh example.sh"), and close all file descriptors like this: for fd in $(ls /proc/$$/fd); do case "$fd" in 0|1|2) ;;...
user avatar
  • 1
0 votes
2 answers
26 views

Sourcing file in dash with . file gives "not found" error

I'm trying to source (bash-parlance) a file in dash using . file as specified by the man page: . file The commands in the specified file are read and executed by the shell. But I ...
user avatar
3 votes
0 answers
71 views

What parts of dash are not part of the POSIX standard?

I know that dash adheres quite closely to the POSIX standard, but I know that it's not 100.00% strict POSIX without any extras. The shell that comes closest/adheres exactly to the POSIX standard is as ...
user avatar
1 vote
1 answer
52 views

SHELLOPTS equivalent for /bin/dash

I have to run a number of shell scripts that are defined by a third party. So I cannot (or would prefer not to) change their content or which shell (bash vs. dash) they are using. They may or may not ...
user avatar
0 votes
1 answer
41 views

Incorrect order of commands in "Command Substitution" (Bash/Dash)

Why is it that when you run the substitution commands, the order of execution is broken, as in the example below. First the chmod command was executed, then echo 1 and echo 2? echo $(echo 1; echo 2; ...
user avatar
  • 127
0 votes
0 answers
49 views

Secure transfer of arguments to a program (dash/bash)

Transfer via stdin #!/bin/dash echo 'password' | program - Transfer via stdin using an intermediate variable var_pass=$(echo 'password') echo $var_pass | program - unset var_pass Transfer via ...
user avatar
  • 127
0 votes
1 answer
54 views

Proper way to wrap dash using rlwrap

On Ubuntu, I have set alias sh='rlwrap --complete-filenames sh' to get readline keybindings and filename completion when using the dash shell (on my computer, sh is /usr/bin/sh, which is a symbolic ...
user avatar
  • 1,832
-1 votes
3 answers
74 views

Changing the place operator in a csv file

I've been editing a CSV file so I can import it into postgres. At this point I want to change the operator from column 5 to the left side of the column when the value is negative"-". When it ...
user avatar
0 votes
3 answers
69 views

find/detect file name goups

On fs i have files like: PREFIX_GROUPNAME_OTHERNAMES[.txt|.*] eg: A_ABC_A.txt A_ABC_B.txt A_ABC_C.txt A_XYZ_A.txt A_XYZ_B.txt A_XYZ_C.txt For some futher tasks i want to get the group names. $# ...
user avatar
  • 11
2 votes
0 answers
42 views

Can't grep or word count the output of jobs command in dash

This is what I tested in Arch's dash shell and FreeBSD's default sh shell, the results are the same. $ sleep 100 & $ jobs [1] + Running sleep 100 $ jobs | wc 0 0 ...
user avatar
  • 21
-1 votes
1 answer
83 views

purpose of dashes in `wget -qO- https://get.speedify.com | bash -`

In this command: wget -qO- https://get.speedify.com | bash - Source: https://support.speedify.com/article/562-install-speedify-linux ...the first -q is the option for "quiet" mode. What is ...
user avatar
1 vote
1 answer
268 views

ssh: force different shell for non-interactive command execution

how can I force specific shell to be used for non-interactive command execution via ssh on remote server? My default shell on the remote server is zsh, but I need to execute given command using /bin/...
user avatar
5 votes
1 answer
464 views

/bin/sh: wildcard expansion does not work in script

I am using dash as /bin/sh. In my script, I have following line: SSH_AUTH_SOCK=/tmp/ssh-????????????/agent.* Which is supposed to match file /tmp/ssh-abcdefghijkl/agent.1234. Even when the file ...
user avatar
0 votes
2 answers
111 views

How to execute a one-line posix dash command within dash script to enable coredump?

For unrelated purposes I am forced to produce a script that only works with posix sh. Within my script I have checked if the system allows the creation of coredumps, then if the limit is set to 0 I ...
user avatar
3 votes
1 answer
55 views

dash and local keyword not resetting shell

dash shell (unlike bash and busybox ash implementation where both examples print foo: '') takes value of previously defined variable, i.e. guarding with local does not work: $ foo=ee; bar() { local ...
user avatar
  • 1,339
-1 votes
1 answer
109 views

Having an interactive shell experience but running everything through dash

So i'm starting to get addicted to POSIX standards and simplicity yet i hate not having autocomplete using the arrows to go through characters and i want a cool shell prompt. so is there anyway that i ...
user avatar
  • 113
0 votes
0 answers
63 views

Why integer division is faster than bitwise shift in shell?

I'm comparing performance of bash and dash (default sh in Xubuntu 18.04). I expect sh to be faster than bash I expect bitwise shift to be faster than division operator. However, I'm getting ...
user avatar
1 vote
2 answers
69 views

Can't delete multiple files with spaces on name with rm

I'm working on a deploy script for my dotfiles, they are stored on a Git bare repository, from which i git checkout it's files into my home directory, in order to seamlessy do it without thousands of ...
user avatar
-4 votes
1 answer
591 views

How to printf ascii characters with hex or dec inside /bin/sh -c '...'?

/bin/sh would be dash what is the correct syntax for printf to display certain ascii character using hex or dex code in dash? let's say i want to printf a dollar sign ($). which hex or dec code should ...
user avatar
0 votes
1 answer
121 views

Global Variables across scripts [duplicate]

Why is lets say HOME recognized by all my scripts but my variable DMENU isn't? I export it in my bspwmrc file which is executed at start up.Also had it in my zshrc. Why do this? DMENU="-h 27 -z ...
user avatar
  • 23
0 votes
1 answer
73 views

su not working inside arch-chroot with dash shell

When i try to do the following inside a dash script: #!/bin/dash arch-chroot /mnt /bin/dash <<- EOF su myuser whoami EOF It simply logs the "root", but when i try to do it ...
user avatar
10 votes
2 answers
1k views

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 (...
user avatar
4 votes
2 answers
272 views

bash -e and && evaluation inside functions

I'm puzzled by bash (and dash) behavior when -e option is set. Simple example: #!/bin/bash -e func() { false && true } false && true echo "1" func echo "2" ...
user avatar
  • 43
1 vote
2 answers
157 views

/bin/sh evaluates string while Bash does not

When running the script below, I get two different outputs, depending on whether or not the shell used is sh or bash: regex(){ echo 's/\(.* \)\(!\{0,1\}\)has(/\1\2MOCK_has(/g' } replace_builtins(...
user avatar
  • 911
1 vote
1 answer
56 views

Can't use variables while feeding commands to bash through stdin

I need to run a small shell script using C popen call (which calls sh -c '<command>'). I can't get my script to work. I isolated the issue to this snippet: #!/bin/bash sh -c 'bash -xev -s <&...
user avatar
  • 121
3 votes
2 answers
266 views

Why does printf byte formatting fail when executed under `dash`?

The ASCII hex code for a zero is 0x30. Hence, you can print a zero by doing printf '\x30', and it will print a zero. If you put this into a shell script called myScript.sh, and then execute ./myScript....
user avatar
  • 41
-1 votes
1 answer
194 views

variable regex test in dash?

I got plenty possible variables in a form of [a-z][0-9], eg 1 letter and 1 number. Is there a way to test them in dash? Something like: myvar=o7 if [ $myvar=o[0-4] ]; then "do this" elif [ $...
user avatar
0 votes
1 answer
75 views

dash: How can I quote the arguments ala "${(q+@)@}" in zsh?

I want to quote the arguments in dash (or sh, or even bash if that's not possible). I can do that with "${(q+@)@}" in zsh, such that reval <sth> ... is the same as just typing in <...
user avatar
  • 1,287
0 votes
1 answer
128 views

cmd nested in backticks processed from sudo?

Are nested `commands` using (deprecated) backticks executed with root permissions (from sudo command line) while command substitution $(...) is not? for example sudo mount `blkid -u /dev/sda1` ... ...
user avatar
  • 519
2 votes
1 answer
92 views

emulate zsh multios in dash (multiple redirections)

in zsh, when the option multios is enabled, I can pipe output to two different processes, ie: cat /dev/sda > sda.img | sha256sum > sda.img.sha256 How could I achieve the same in dash, ie /bin/...
user avatar
2 votes
0 answers
176 views

Trap on DEBUG signal for the ash and dash shells?

With the bash shell, you can install a trap on the synthetic DEBUG signal. This is useful and will execute your function or bit of code on every shell command. Not so in ash or dash. $ trap 'echo hi' ...
user avatar
2 votes
1 answer
428 views

Do all POSIX shells implement arithmetic expansion $((...)) in the same way? [duplicate]

I'm trying to write a shell script which should work under any POSIX shell, and I found what seems to be an odd quirk of dash. I'm wondering whether this is something I can rely on working under other ...
user avatar
  • 850
0 votes
1 answer
32 views

dash: echo args exactly with no processing

I want to do sth like zsh's print -r -- ... which just echoes the arguments without changing them at all. printf -- still interprets directives.
user avatar
  • 1,287
-2 votes
2 answers
95 views

execlp() system call

I want to call the ulimit shell command through a C program. right now, I have: execlp("ulimit", "ulimit", "-u", "%d", ulimit_a); It compiles fine, but does not actually edit the user-id max ...
user avatar
  • 19
7 votes
1 answer
4k views

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 ...
user avatar
  • 1,924
1 vote
0 answers
22 views

length of the command line buffer [duplicate]

Which's the length of the command line buffer, per shell... and per operating system (if applicable)? Mostly interested in contemporary versions of Dash and Bash and Debian and macOS, but if anyone ...
user avatar
  • 87
2 votes
2 answers
846 views

Why does SIGTERM work to terminate bash but not ash or dash?

Comparing bash, ash and dash, only bash can be terminated by SIGTERM kill -TERM <pid> For ash and bash, I need SIGHUP or SIGKILL kill -HUP <pid> kill -KILL <pid> What's the ...
user avatar
  • 1,924
0 votes
1 answer
459 views

Dash non-interactive non-login rc file

Does dash have a non-interactive non-login rc file? I've read the man page, which recommends .profile for login shells and $ENV environment variable for interactive shells. Is there anything that ...
user avatar
  • 454
1 vote
1 answer
496 views

How to kill all background jobs in dash?

Simply kill $( jobs -p ) not work in dash. For example in dash: $ sleep 999 & $ kill $(jobs -p) dash: 2: kill: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or kill -l [...
user avatar
2 votes
1 answer
136 views

No /var/lib/dpkg/info/dash.preinst in Buster

In https://wiki.debian.org/Multistrap#Steps_for_Squeeze_and_later, it's required to run the following command in chroot environment: /var/lib/dpkg/info/dash.preinst install This command runs in ...
user avatar
  • 1,937
6 votes
2 answers
1k views

Are shells allowed to ignore NUL bytes in scripts?

Because that's what some of them are doing. > echo echo Hallo, Baby! | iconv -f utf-8 -t utf-16le > /tmp/hallo > chmod 755 /tmp/hallo > dash /tmp/hallo Hallo, Baby! > bash /tmp/hallo /...
user avatar
4 votes
2 answers
734 views

Is there a way to make the local command work portably to dash ksh bash and zsh?

In dash (and in bash zsh and some other shells) the command local works to make a variable scope limited to that function (and descendants in some cases). That enable the possibility of making a ...
user avatar
  • 38.8k
4 votes
2 answers
326 views

Why the parent shell here-document not work for sub-command in dash but bash work?

I'm run on debian stretch, all below commands(dash and bash) is input to bash. The whoami seem never run as the user test in dash as in below codes. $ sudo dash << 'end' > su test > ...
user avatar
3 votes
1 answer
518 views

Putting "$@" in a local variable in dash

I have a Bash function that does some string manipulation on its arguments as a whole ("$@") by putting it in a local variable, something like this: #!/bin/sh my_func() { local args="$@" ...
user avatar
0 votes
3 answers
3k views

I would like to check if a file name matches a certain pattern

I would like to check if a file name matches a certain pattern start with an alphanumeric character ([a-zA-Z0-9]) and will only contain alpha-numeric characters plus '.', '-' and '_' characters. ...
user avatar
8 votes
2 answers
574 views

dash not expanding glob wildcards in chroot

I'm working with a copy of Raspbian, installed with pi-gen. Pi-gen runs in a Docker container with a volume for the filesystem, running debootstrap and custom scripts inside a chroot to the volume. I'...
user avatar
6 votes
3 answers
2k views

Why does ''cat "${1:-/dev/stdin} | ... &>/dev/null'' work in bash but not dash?

Script: #!/bin/sh # # reads stdin/file and copies it to clipboard # clears it after 30s # cat "${1:-/dev/stdin}" | timeout 30 xclip -i -selection clipboard -r -verbose &>/dev/null & I ...
user avatar
  • 71
7 votes
3 answers
1k views

Shell builtin `printf` line limit?

The /usr/bin/printf util argument list length is limited to the shell's maximum command line length, (i.e. getconf ARG_MAX, on my system that'd be 2097152); example: # try using a list that's way too ...
user avatar
  • 6,776