Skip to content

[Bug] startup.sh fails on Ubuntu due to dash incompatibility with [[ syntax #15171

Description

@lengmodkx

Describe the bug
On Ubuntu/Debian systems, /bin/sh is symlinked to dash by default. The startup.sh script uses [[ bash syntax (e.g., line 172, 176, 184, 186, 193, 219, 232), which dash does not support. Running sh bin/startup.sh -m standalone results in multiple [[: not found errors, and the -m standalone parameter is not parsed correctly (Nacos starts in cluster mode instead).

Expected behavior
sh bin/startup.sh -m standalone should work correctly on Ubuntu/Debian, or the script should explicitly require bash.

Actual behavior

root1@root1-2288H-V5:~/nacos/nacos$ sh bin/startup.sh -m standalone
bin/startup.sh: 172: [[: not found
bin/startup.sh: 176: [[: not found
bin/startup.sh: 184: [[: not found
bin/startup.sh: 186: [[: not found
bin/startup.sh: 193: [[: not found
...
nacos is starting with cluster    # -m standalone was ignored

How to Reproduce
Steps to reproduce the behavior:

  1. Use Ubuntu 22.04/24.04 (or any Debian-based system where /bin/sh -> dash)
  2. Download and extract Nacos 3.2.1
  3. Run sh bin/startup.sh -m standalone
  4. See [[: not found errors and cluster mode startup

Environment

  • OS: Ubuntu 22.04/24.04
  • Nacos Version: 3.2.1
  • JDK: 17

Suggested Fix
Option A: Change shebang from #!/bin/sh to #!/bin/bash
Option B: Replace all [[ ... ]] with POSIX-compatible [ ... ]

Additional context
Using bash bin/startup.sh -m standalone works as a workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementCategory issues or prs related to enhancement.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions