XCODX |

Dash Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About Dash

Dash is the Debian Almquist Shell, the small, fast POSIX shell that Debian and Ubuntu use as /bin/sh to run boot and system scripts. It descends from Kenneth Almquist's ash, was ported to Debian by Herbert Xu, and deliberately implements little more than the POSIX shell specification — no arrays, no [[ ]], no process substitution — which is exactly what makes it a strict test of portability. Because it starts faster and carries far less code than Bash, distributions reach for it wherever startup time and predictability matter; and because it rejects Bash extensions, a script that runs in Dash will run on almost any Unix shell, from Alpine containers to BusyBox devices. The language still gives you variables, the read builtin, if and case, while and for loops, functions, and $(( )) arithmetic. On XCODX this page runs real Dash in a live terminal, so read pauses for your keystrokes and there is nothing to install; the version is shown in the badge.

Hello World in Dash

#!/bin/sh
# Reads lines until end-of-input (Ctrl+D) and tallies them.
lines=0
words=0

while IFS= read -r line; do
    lines=$((lines + 1))
    # split the line into positional params to count words, POSIX-style
    set -- $line
    words=$((words + $#))
    printf 'line %d: %d word(s)\n' "$lines" "$#"
done

echo "----"
echo "Total lines: $lines"
echo "Total words: $words"
case $lines in
    0) echo "No input given." ;;
    1) echo "Just the one line." ;;
    *) echo "Read $lines lines in all." ;;
esac

When to use Dash

Dash matters most when portability does: writing Docker entrypoint scripts for Alpine images, Debian maintainer scripts, or anything with a #!/bin/sh shebang that has to survive on minimal systems where Bash may not exist. Choose this page to check whether a script secretly depends on Bashisms — paste it in and Dash's errors point straight at the array, [[ ]], or ${var//.../...} that would break elsewhere — and to practice the POSIX subset that textbooks, exams, and portable scripts assume. Working through read loops, case statements, and $(( )) arithmetic here builds shell skills that transfer to every Unix shell. It is a poor fit for anything that leans on interactive conveniences or Bash-only features, and, like any shell, for logic that grows complex enough that a real programming language becomes the safer choice.

Common questions

Does the read builtin wait for my input here?

Yes. read pauses the script and waits for a line from the terminal, and because this is a live interactive session your typed input goes straight to stdin, exactly as it would over SSH on a real server. Prompts printed with printf appear before the pause. Ctrl+D signals end-of-input, which is how a while read loop knows to stop, and you can also paste input into the Stdin Box.

How is Dash different from Bash?

Dash implements the POSIX shell and very little beyond it, so Bash-only features — arrays, [[ ]] tests, (( )) arithmetic commands, process substitution, and ${var//find/replace} expansions — are not available. In return it is much smaller and starts faster, which is why Debian and Ubuntu point /bin/sh at it. A script that runs cleanly in Dash is highly portable across other shells.

Can I apt-get install a tool or download something in the script?

No. The sandbox has no network and no package-manager privileges, so apt-get, curl, and wget have nothing to reach and nowhere to install to. You get Dash plus the basic Unix utilities that ship in the image; anything outside that base set is unavailable and cannot be added. Write scripts that depend only on the shell and common tools.

Why does my script work in Bash but fail in Dash?

Almost always because it uses a Bashism that Dash does not implement — declaring an array, using [[ ... ]] instead of [ ... ], writing function name() with the function keyword, or ${var//a/b} replacement. Dash follows POSIX strictly and reports these as syntax errors, which is exactly why testing here catches portability bugs before a script reaches /bin/sh on another system. Rewrite the flagged part with POSIX-equivalent syntax.

Do files my script creates stick around between runs?

No. Every run gets a clean, temporary filesystem, so a file you create with a > redirect or touch exists only for that run and is removed afterward. That is fine for scratch work within a single script; just do not expect anything to survive to the next run. Keep needed data inside the script or its input.

Is this really Dash, and do I need a #!/bin/sh line?

Yes, it is the real Dash shell, not an emulation, so POSIX features behave as the specification says and Bash extensions genuinely fail. A #!/bin/sh shebang documents intent and is good practice, but the page runs your script with Dash whether or not you include one. That makes it a reliable stand-in for the /bin/sh environment on Debian and Alpine systems.

How Dash runs on XCODX

Sandbox filename
main.sh
Entry point
single main source file
Editor grammar
shell
Reading stdin
read
Input delivery
live WebSocket stream
Prompt flushing
flushes before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

#!/bin/dash
# Dash - Debian Almquist Shell
echo "Hello from Dash!"
echo "Welcome to XCODX Online Compiler!"

# Variables and arithmetic
COUNT=5
echo "Counting to $COUNT:"
I=1
while [ "$I" -le "$COUNT" ]; do
    echo "  Number: $I"
    I=$((I + 1))
done
echo "Done!"