diff --git a/src/ddmd/mars.d b/src/ddmd/mars.d index c9cf32b168e2..ed966561ab4a 100644 --- a/src/ddmd/mars.d +++ b/src/ddmd/mars.d @@ -2156,7 +2156,10 @@ private bool parseCommandLine(const ref Strings arguments, const size_t argc, re error("-run must be followed by a source file, not '%s'", arguments[i + 1]); break; } - files.push(arguments[i + 1]); + if (strcmp(arguments[i + 1], "-") == 0) + files.push("__stdin.d"); + else + files.push(arguments[i + 1]); params.runargs.setDim(length - 1); for (size_t j = 0; j < length - 1; ++j) { diff --git a/test/runnable/test18076.sh b/test/runnable/test18076.sh new file mode 100755 index 000000000000..11ce77cf380c --- /dev/null +++ b/test/runnable/test18076.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +dir=${RESULTS_DIR}${SEP}runnable +output_file=${dir}/test18076.sh.out + +echo 'import std.stdio; void main() { writeln("Success"); }' | \ + $DMD -m${MODEL} -run - > ${output_file} || exit 1 +grep -q '^Success$' ${output_file} || exit 1