Skip to content

Pause Until Enter

Block until the user presses Enter, then continue; treat end-of-file as a clean exit so piped input does not hang.

Language: Shell

Added on: 18th August 2026

pause() {
  printf "\nPress Enter to continue..."
  if ! read -r _; then
    printf "\nEOF; exiting.\n"
    exit 0
  fi
}

Caveats

Exits the whole process on EOF (for example Ctrl-D).