I believe that dart --version
is writing out to standard error rather than standard output. (See https://code.google.com/p/dart/codesearch#dart/trunk/dart/runtime/bin/main.cc&sq=package:dart&q=ProcessVersionOption&l=588.) So when you see your script print Dart VM version: ...
, that's actually coming from the DART_VER=$(dart --version)
(which prints Dart VM version: ...
to standard error, and sets DART_VER
to the empty string) rather than the echo "${DART_VER}"
(which just prints the empty string, plus a newline).
You can fix that by changing this:
DART_VER=$(dart --version)
to this:
DART_VER=$(dart --version 2>&1)
to merge standard error into standard output for capture.